自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(16)
  • 收藏
  • 关注

原创 Rotate Array--Leetcode(Java)

public void rotate(int[] nums, int k) { int n = nums.length; k %=n; reverse(nums, 0, n-k-1); reverse(nums, n-k, nums.length-1); reverse(nums, 0, nums.length-1);

2015-02-26 20:41:12 1409

原创 Longest Consecutive Sequence--Leetcode(Java)

Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is [1, 2, 3

2015-02-26 19:14:22 478

原创 Minimum Window Substring

听一个朋友说她facebook onsite考了这题原题,果断有动力刷起。看了leetcode上的思路,讲的非常清晰,特别是他画的图,很直观。 http://leetcode.com/2010/11/finding-minimum-window-in-s-which.html思路是维护一个窗口,窗口一直满足包含所有T中的字符。作者里面是维护两个array, 一个needToFind,

2015-02-25 04:20:39 509

原创 Copy List with random pointer--Leetcode(Java)

leetcode easy和medium的题总算刷完了。认真刷Hard了,Hard题重思路。这题的思路就是复制原来的list, 每个node都double, 然后copy random pointer就是相当于node.next.random=node.random.next, random依次指向下一个。最后分开两个list, return copy list.  public R

2015-02-25 04:14:39 469

原创 LCA of Binary Tree

TreeNode findLCA(TreeNode root, TreeNode p, TreeNode q) { // no root no LCA. if(!root) { return NULL; } // if either p or q is the root then root is L

2015-02-24 00:52:57 448

原创 Reverse Integer--LeetCode(Java)

我这进度太慢了,能写多少是多少了。这个很简单的题,我开始却想复杂了。其实就是从个位开始,每次*10 再加上新的前一位。 public int reverse(int x) { int res = 0; while(x!=0){ res = res*10+x%10; x /= 10;

2015-02-22 19:40:59 434

原创 Search in Rotated Sorted Array 1 &&2 -- LeetCode (Java)

怎么差了一个等号就对了呢?:(我需要冷静下,让我思考下 这儿A[l] if(A==null||A.length==0){ return -1; } int l=0; int r=A.length-1; while(l<=r){ int m = l+(r-l)/2

2015-02-07 05:24:57 474

原创 Sqrt(x) -- LeetCode (Java)

哇!自己做出来的bug free的二分法题,好开心!上code public int sqrt(int x) { if(x==0){ return 0; } if(x<0){ return -1; } int l = 1; int r = x

2015-02-07 04:25:06 454

原创 Search for a Range - Leetcode (Java)

参考了code ganker大牛,http://blog.csdn.net/linhuanmars/article/details/20593391二分法边界条件老是想不明白, 不知道等号到底归在哪边。这题也想了好久。既然要找边界,左边就是不停往左,右边就是不停往后。所以找左边边界的时候,A[m]=target的情况是放在左边继续递归的。然后右边找边界的时候,A[m]=target的情况诗放在

2015-02-07 00:51:00 544

转载 Find Minimum in Rotated Sorted Array - Leetcode (Java)

public int findMin(int[] num) { int s = 0; int e = num.length-1; int m; while(s<e){ m = (s+e)/2; if(num[m]>=num[s] && num[s] > num[e])

2015-02-06 23:03:08 541

原创 LeetCode – Maximum Gap (Java)

这题是用桶排序,做的时候犯了三个错:1. 最大最小值的array一开始没有设置初始值,那当然会错,因为最小会一直停留在0那里:(2. 忘记check corner case, 就是数组长度小于等于2的情况3. 空桶要跳过,直接挨着顺序看桶,那也必错。下面是通过的Leetcode AC的 public int maximumGap(int[] num) {

2015-02-06 22:31:56 774

原创 LeetCode – Flatten Binary Tree to Linked List (Java)

这题参考了Code Ganker大牛思路http://blog.csdn.net/linhuanmars/article/details/23717703设置pre结点,每次pre左结点设置为空,右结点设置为当前结点。有一点特别要注意的是Java是pass by value,所以需要用一个单元素的TreeNode数组来储存并且改值。ArrayList pre = new

2015-01-25 04:12:05 501

原创 LeetCode – Remove Element (Java)

这题和上题思路完全一致, 双指针. 有了前一题的断

2014-08-29 05:34:57 470

原创 LeetCode – Remove Duplicates from Sorted Array (Java)

上一篇博客我转了leetcode level of difficulty. 我打算从

2014-08-29 04:24:33 472

转载 Leetcode Problem difficulty level and frequency table(zz)

Source: http://leetcode.cloudfoundry.com/Author: peking2 Leetcode QuestionsIdQuestionDifficultyFreqencyData StructuresAlgorithms1Two Sum25arraysetso

2014-08-29 04:22:30 817

原创 关于我和我的这个博客

本人女程序媛, 外加女博是

2014-08-29 04:05:00 668

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除