Grokking the Coding Interview: Patterns for Coding Questions
Vote

0% completed

Introduction to Modified Binary Search Pattern

You are given a sorted array and a target. Find the smallest value that is greater than or equal to the target.

This value is called the ceiling.

[1, 3, 8, 10, 15]    target = 12    ceiling = 15

Normal binary search looks for an exact match. If 12 is missing, it usually returns "not found."

This problem needs information about the position where 12 would be inserted.

Binary search already finds that position. When start and end cross, start points to the first value greater than the target.

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content