BINARY SEARCH dual presence

For binary search if my input is as follows:

8
1 2 3 2 5 7 9 5
2

, it shows that element found at index at 3… Is there any way I can make it show the element’s first presence i.e. 1?

Hey @diganta_7777
You should not run Binary search on this

You are forgetting the basics of Binary Search that it can only be applied to Sorted array .

Oh! Sorry! Yes Understood! Thank You!

1 Like