codeintuition-logo

Understanding the problem


Even after learning about binary search, there are situations where simply finding a target value is not enough. Sometimes, we need to locate a specific position, for example, the first occurrence of a value in a sorted list, which binary search alone does not directly provide. To see why this can be a problem, let’s look at an example.

Example

Imagine you are a school teacher with a sorted list of thousands of students. Several students scored 85 marks, and you want to identify the student who appears first in the list with that score.

Liking the course? Check our discounted plans to continue learning.