Understand conceptually how binary search works
Know how to implement binary search in code
Binary search allows us to search a sorted array for a target number in O(logn)
time. The following videos explain the concept.
Consider the following canonical binary search implementation.
After attempting each problem, find solutions in the Leaderboard tab (HackerRank, may be on left side of page) or Solution or Discuss tabs (LeetCode) on that problem's page. If you get stuck for more than 15 minutes, review and understand the solutions and move on. Come back and re-attempt the problem after a few days.
Binary Search (LeetCode)
Rocket solution code (Python)
Rocket solution video (Python)
First Bad Version (LeetCode)
Valid Perfect Square (LeetCode)
Search Insert Position (LeetCode)
Two Sum II Input Array is Sorted (LeetCode)
Count Negative Numbers in a Sorted Matrix (LeetCode)
Rocket solution code (Python)
Rocket solution video (Python)