17 Binary Search
2分模板:
L462 Total Occurrence of Target
普通2分:
74 Search in a 2D Matrix (L28)
240 Search in a 2D matrix II (L38)
162 Find Peak Element (L75)
L585 maximum Number in Mountain Sequence
35 Search Insert Position (L60)
L447 Search in a Big Sorted Array (702)
L459 Closest Number in Sorted Array
L460 K closest Numbers in Sorted Array
744 Find Smallest Letter Greater Than Target
1228 Missing Number In Arithmetic Progression
复杂一点的2分搜索:
540 Single Element in a Sorted Array
34 Search for a Range (L61)
302 Smallest Rectangle Enclosing Black Pixels - 还可以用bfs,不过2分比较好 (L600)
275 H-Index II -- 九章模板套不了,二分终极版
1539 Kth Missing Positive Number -- 九章模板套不了,好像那些答案不在中间的都挺难套九章二分的
1712 Ways to Split Array Into Three Subarrays
二分答案:这种题的 T:O(nlog(answer range)),只能用于答案range是连续而且有一个分界点。写法:一个用来筛选答案的2分函数,在主函数里调用这个函数2分地找。
287 Find the Duplicate number -- 竟然还能用142 Linked List Cycle II的解法
374 Guess Number Higher or Lower
L437 copy books I - can also use DP
L438 copy books II - can also use DP
410 Split Array Largest Sum - can also use DP
pramp mock test 2,grant cut
L141 Sqrt(x) (69)
RootOfNumber -- pramp,进化版的L586 Sqrt(x) II
L254 Drop Egg - ctci 6.8
L617 maximum Average Subarray
与树相关的2分:
230 Kth Smallest Element in a BST
270 Closest Binary Search Tree Value - pramp 3 - TreeSet flooring / celing / lower / higher
Other related:
375 Guess Number Higher or Lower II - DP or MiniMax
L586 Sqrt(x) II --- 牛顿法
L584 Drop Eggs II -- DP
感觉比较难的二分?:
Last updated