摘要: A peak element is an element that is greater than its neighbors.Given an input array wherenum[i] ≠ num[i+1], find a peak element and return its index.... 阅读全文
posted @ 2015-02-16 22:20 Sherry是小太阳 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 思路就是砍一半, 适用于sorted array.时间复杂度O(lgn).每次都是取中间的跟target比较, 比target小的话目标值肯定在lower和mid之间, 比target大的话在mid和high之间~ 1 public int binarySearch(int num[], int t... 阅读全文
posted @ 2015-02-16 10:15 Sherry是小太阳 阅读(104) 评论(0) 推荐(0) 编辑
摘要: Given an array of sizen, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋times.You may assume that the arr... 阅读全文
posted @ 2015-02-16 09:49 Sherry是小太阳 阅读(112) 评论(0) 推荐(0) 编辑
摘要: Given an integern, return the number of trailing zeroes inn!.Note:Your solution should be in logarithmic time complexity.Credits:Special thanks to@tsf... 阅读全文
posted @ 2015-02-16 02:37 Sherry是小太阳 阅读(110) 评论(0) 推荐(0) 编辑