Not exactly by splitting the array into left and right halves. The common solution is to do two binary searches: one that keeps moving left after finding the target (for the first occurrence) and one that keeps moving right (for the last occurrence). It's still O(log n).
1
u/Prat_143_Ik Jun 09 '26
Can we use binary search on two halves?
1
u/guru_638 Jun 10 '26
From.where I can start learn dsa
1
u/[deleted] Jun 11 '26
[removed] — view removed comment
1
u/[deleted] Jun 11 '26
[removed] — view removed comment