摘要:
O(logN) Check four different situations: 1) The peek 2) increasing section 3) decreasing section 4) minimum 阅读全文
摘要:
O(logN) There are two section: 1) increase array which the first element is larger than end one. 2) the minimum to end Comparing with the endVal, 1) i 阅读全文
摘要:
O(logN) 阅读全文
摘要:
O(logN) Important Point: if there "mid" exists, it has at laest three elements in "nums", because otherwise it will not come inside the loop. So later 阅读全文
摘要:
class Solution { /** * @param x: An integer * @return: The sqrt of x */ public int sqrt(int x) { // write your code here if (x < 0) { return -1; ... 阅读全文
摘要:
If it is two eggs: http://datagenetics.com/blog/july22012/index.html Imagine we drop our first egg from floor n, if it breaks, we can step through the 阅读全文
摘要:
public class Solution { /** * @param A an integer array sorted in ascending order * @param target an integer * @return an integer */ public int totalOccurrence(int[] A, in... 阅读全文
摘要:
Method One: Using Binary Search Once. The point is how to calculated the number's index. mtarix[<num> / nCol][<num> % nCol] Method Two:Binary Search T 阅读全文
摘要:
O(logN) 阅读全文
摘要:
O(logN)For the last element, if nums[mid] == target, we threw the first part 阅读全文