二分法

常见的二分法题目可以分为两大类,显式与隐式,即是否能从字面上一眼看出二分法的特点:要查找的数据是否可以分为两部分,前半部分为 X,后半部分为 O

显式二分法:

  • Leetcode 34。Find First and Last Position of Element in Sorted Array
  • Leetcode 33。Search in Rotated Sorted Array
  • Leetcode 1095。Find in Mountain Array
  • Leetcode 162。Find Peak Element
  • Leetcode 278。First Bad Version
  • Leetcode 74。Search a 2D Matrix
  • Leetcode 240。Search a 2D Matrix II

隐式二分法:

  • Leetcode 69。Sqrt(x)
  • Leetcode 540。Single Element in a Sorted Array
  • Leetcode 644。Maximum Average Subarray II
  • Leetcode 528。Random Pick with Weight
  • Leetcode 1300。Sum of Mutated Array Closest to Target
  • Leetcode 1060。Missing Element in Sorted Array
  • Leetcode 1062。Longest Repeating Substring
  • Leetcode 1891。Cutting Ribbons
最后更新: 2/27/2024, 6:53:03 AM