摘要:
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 阅读全文
摘要:
O(logN) 阅读全文
摘要:
Important point: 1) While (start + 1 < end) 2) int mid = start + (end - start)/2;3) check both nums[start] and nums[end] at the end 阅读全文