- 博客(8)
- 收藏
- 关注
原创 Anagrams
public List anagrams(String[] strs){ String cur, key; HashMap map = new HashMap(); List ans = new ArrayList(); for(int i = 0; i { cur = strs[i];
2015-05-15 01:25:44 211
原创 Implement strStr() KMP算法
public class Solution { public int strStr(String haystack, String needle) { if(needle == null || needle.length() == 0) return 0; if(haystack == null || haystack.len
2015-05-05 10:38:45 268
原创 [LEETCODE]Populating Next Right Pointers in Each Node
5行解决呵呵~public class Solution { public void connect(TreeLinkNode root){ //由于题目的特殊性可以采取层序遍历的方法来求解 注意是满的完全的二叉树这个条件很强大 if(root == null || root.left == null) return; root.
2015-05-03 20:45:30 230
原创 Merge Two Sorted Lists
代码1:/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */public class Solution { public ListNod
2015-04-30 11:27:35 220
原创 Bitwise AND of Numbers Range
public class Solution { public int rangeBitwiseAnd(int m, int n) { int ans = 0; /* if(m == n) return m; */ int probe = 1<<31;//100000...00 32位一共
2015-04-28 23:38:39 269
原创 leetcode Excel Sheet Column Title
public class Solution { int flag[] = new int[26]; { int i; for(i = 1; i <= 25; i++) flag[i] = 'A' + i - 1; flag[0] = 'Z'; } int ans[] = new int[10];
2015-04-27 22:39:38 209
原创 Reverse Bits
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 001110010
2015-04-27 11:57:06 245
原创 LEETCODE 203 Remove Linked List Elements
删除链表当中指定key的项 链表的遍历与删除操作唯一需要注意的是,删除head节点和删除其他节点不一样/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; }
2015-04-25 18:36:38 234
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人