
JAVA
文章平均质量分 53
ivanmerlin
这个作者很懒,什么都没留下…
展开
-
JAVA GUI PART1 记事本程序 极其简易版
JMenuBar 菜单栏JMenu 菜单项JMenuItem 菜单项弹出来的子菜单项FileDialog 用来访问本地文件的对话框 (frame,string,int)以下为建议修改版记事本import java.awt.EventQueue;public class Textbook { private JFrame frame; JMenu mnFile原创 2014-01-25 21:21:25 · 777 阅读 · 0 评论 -
Reverse Linked List 翻转链表
Reverse a singly linked list.单向链表是个难点。一开始用栈来做,结果报了内存超过了。后来想到用指针来做。保存第二个元素的下一个节点,让他们依次反序指向即可/** * Definition for singly-linked list. * public class ListNode { * int val; *原创 2015-09-16 23:42:23 · 328 阅读 · 1 评论 -
Excel Sheet Column Number
Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ...原创 2015-09-16 21:49:30 · 304 阅读 · 0 评论 -
Majority Element
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element原创 2015-09-16 22:10:28 · 292 阅读 · 1 评论 -
Single Number
Given an array of integers, every element appears twice except for one. Find that single one.大意就是,别的数字都成双成对,只有一个数字孤身一人。【别名:寻找单身狗】Note:Your algorithm should have a linear runtime complexity翻译 2015-09-30 10:13:03 · 288 阅读 · 0 评论 -
最长单词
给一个词典,找出其中所有最长的单词样例在词典{ "dog", "google", "facebook", "internationalization", "blabla"}中, 最长的单词集合为 ["internationalization"]在词典{ "like", "love", "hate", "yes"}中原创 2015-09-11 11:12:50 · 352 阅读 · 0 评论 -
翻转二叉树
样例 1 1 / \ / \2 3 => 3 2 / \ 4 4通常使用递归的办法public class Solution { /** * @param root: a TreeNode, the root of the binary tree * @原创 2015-09-11 10:30:12 · 378 阅读 · 1 评论 -
O(1)检测2的幂次
用 O(1) 时间检测整数 n 是否是 2 的幂次。这个问题一开始我是想用求Log的方法算 public static boolean checkPowerOf2(int n) { // write your code here if(n<=0) return false; double answer=Math.log(n)/Ma原创 2015-09-11 09:53:53 · 455 阅读 · 0 评论 -
乱序字符串
给出一个字符串数组S,找到其中所有的乱序字符串(Anagram)。如果一个字符串是乱序字符串,那么他存在一个字母集合相同,但顺序不同的字符串也在S中。样例对于字符串数组 ["lint","intl","inlt","code"]返回 ["lint","inlt","intl"]注意所有的字符串都只包含小写字母先生成每个字符串的标识,即字母原创 2015-09-10 14:05:31 · 333 阅读 · 0 评论 -
Remove Element 100%哟
Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't matter what you leave beyond the new length.这原创 2015-09-17 14:31:05 · 327 阅读 · 0 评论