CodeMosa

Master LeetCode Patterns

5 Problems

Binary Search Practice Problems

Boundary (lower/upper), rotated arrays, and binary search on answer. Practice classic variations and pitfalls.

Back to Collections

Relevant Patterns

#
Study these pattern guides before tackling the problems. Understanding the core concepts will help you solve them more efficiently.

Practice Problems

#
Show 2 hints
  • Treat isBadVersion(mid) as monotonic predicate.
  • Steer hi = mid on True to find first bad (lower bound).
Show 2 hints
  • Run two boundary searches: < target for left, <= target for right.
  • Return [-1,-1] if target not present.
Show 2 hints
  • At mid, one side is sorted; choose side where target could lie.
  • Avoid explicit pivot search; compare against nums[lo]/nums[mid]/nums[hi].
Show 2 hints
  • Binary search on eating speed; hours is monotone in speed.
  • Use ceiling division when computing hours for a speed.
Show 2 hints
  • Search minimal capacity; feasibility check simulates one pass packing days.
  • lo = max(weight), hi = sum(weight).

Track Your Progress

Mark problems as complete as you solve them. Come back anytime to continue where you left off.