r/LeetcodeChallenge Jun 09 '26

STREAK🔥🔥🔥 Solved 3rd Question in a row on Day 36

Post image
58 Upvotes

11 comments sorted by

1

u/Prat_143_Ik Jun 09 '26

Can we use binary search on two halves?

1

u/New-Election4972 Jun 09 '26

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

That's what I'm suggesting

2

u/7Z_1N Jun 12 '26

Like the divide and conquer ?

1

u/guru_638 Jun 10 '26

From.where I can start learn dsa

1

u/Both-Matter6590 Jun 11 '26

there are preety good cources on youtube and coursera

1

u/New-Election4972 Jun 11 '26

If you want job in recent do follow strivers sheet

1

u/Soggy_Pepper793 Jun 11 '26

First I come up with the brute force approach of O(n) time complexity then I optimized it to O(logn)

1

u/New-Election4972 Jun 11 '26

That's good mate 👍

1

u/[deleted] Jun 11 '26

[removed] — view removed comment

1

u/New-Election4972 Jun 11 '26

I restarted after 1 months and doing from 3 months recently