How to I do a binary search in a multi-list

Viewed 72

I want to do a binary search in a multi-list, by multi-list I mean the values in a list can be multiples. For instance: We have an ordered list [1,1,1,1,1,2,2,2,2,2,3,3,3,3,]. What is the most efficient algorithm to find the index of the first 2 in this list.

enter image description here

How can I improve this result

0 Answers
Related