摘要: Partition ListGiven a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should pres... 阅读全文
posted @ 2014-06-05 16:59 陆草纯 阅读(243) 评论(0) 推荐(0) 编辑
摘要: Best Time to Buy and Sell Stock IISay you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the ... 阅读全文
posted @ 2014-06-02 13:09 陆草纯 阅读(2764) 评论(0) 推荐(0) 编辑
摘要: Sort ListSort a linked list inO(nlogn) time using constant space complexity.要求时间复杂度为O(nlogn),那么不能用quickSort了(最坏O(n^2)),所以使用mergeSort.通常写排序算法都是基于数组的,这题... 阅读全文
posted @ 2014-06-01 20:31 陆草纯 阅读(4535) 评论(1) 推荐(0) 编辑
摘要: Merge Sorted ArrayGiven two sorted integer arrays A and B, merge B into A as one sorted array.Note: You may assume that A has enough space (size that ... 阅读全文
posted @ 2014-06-01 00:01 陆草纯 阅读(235) 评论(0) 推荐(0) 编辑
摘要: Remove ElementGiven 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. ... 阅读全文
posted @ 2014-05-31 23:44 陆草纯 阅读(281) 评论(0) 推荐(0) 编辑
摘要: Jump Game IIGiven an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents... 阅读全文
posted @ 2014-05-30 20:19 陆草纯 阅读(7209) 评论(4) 推荐(0) 编辑
摘要: Rotate ImageYou are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up: Could you do this in-place?最简... 阅读全文
posted @ 2014-05-28 23:25 陆草纯 阅读(264) 评论(0) 推荐(0) 编辑
摘要: Surrounded RegionsGiven a 2D board containing'X'and'O', capture all regions surrounded by'X'.A region is captured by flipping all'O's into'X's in that... 阅读全文
posted @ 2014-05-27 15:21 陆草纯 阅读(3978) 评论(0) 推荐(0) 编辑
摘要: Implement strStr()Implement strStr().Returns a pointer to the first occurrence of needle in haystack, ornullif needle is not part of haystack.解法一:暴力解c... 阅读全文
posted @ 2014-05-26 21:58 陆草纯 阅读(4716) 评论(1) 推荐(0) 编辑
摘要: Remove Duplicates from Sorted ArrayGiven a sorted array, remove the duplicates in place such that each element appear only once and return the new len... 阅读全文
posted @ 2014-05-24 23:20 陆草纯 阅读(202) 评论(0) 推荐(0) 编辑