讨论/《二分查找》 - 二分查找模板 III/
《二分查找》 - 二分查找模板 III

原文在此

https://leetcode.com/explore/learn/card/binary-search/135/template-iii/936/
An alternative way to implement Binary Search
Search Condition needs to access element's immediate left and right neighbors
Use element's neighbors to determine if condition is met and decide whether to go left or right
Gurantees Search Space is at least 3 in size at each step
Post-processing required. Loop/Recursion ends when you have 2 elements left. Need to assess if the remaining elements meet the condition.

我的理解是 搜索条件是 target 的相邻元素在这个区间里

对比一下其他模板的说法就容易理解了
机翻太辣鸡了

1
展开全部 5 讨论