摘要: Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximu... 阅读全文
posted @ 2015-02-25 20:28 vincently 阅读(117) 评论(0) 推荐(0) 编辑
摘要: Implementint sqrt(int x).Compute and return the square root ofx.解法:二分搜索 时间复杂度O(logN), 空间复杂度O(1) 1 class Solution { 2 public: 3 int mySqrt(int x)... 阅读全文
posted @ 2015-02-25 19:04 vincently 阅读(225) 评论(0) 推荐(0) 编辑
摘要: Rotate an array ofnelements to the right byksteps.For example, withn= 7 andk= 3, the array[1,2,3,4,5,6,7]is rotated to[5,6,7,1,2,3,4].Note:Try to come... 阅读全文
posted @ 2015-02-25 18:41 vincently 阅读(632) 评论(0) 推荐(0) 编辑
摘要: 本文转载自:http://www.cnblogs.com/steven_oyj/archive/2010/05/22/1741375.html一、基本概念: 所谓贪心算法是指,在对问题求解时,总是做出在当前看来是最好的选择。也就是说,不从整体最优上加以考虑,他所做出的仅是在某种意义上的局部最优解。 ... 阅读全文
posted @ 2015-02-25 11:55 vincently 阅读(1344) 评论(0) 推荐(1) 编辑