标签:
遇到sorted array 就要想到binary search
模板注意:
1.while (start + 1 < end) 重合或者相邻
2.mid = start + (end - start) / 2 防止溢出
3.A[mid] ==, <, >
4.while 循环结束后分别讨论 A[start/end] == target
题目:
1.Search Insert Position
2.Search for a Range
3.Search in Sorted Rotated Array I & II
4.Search in a 2D Matrix
标签:
原文地址:http://www.cnblogs.com/77rousongpai/p/4287266.html