Skip to content

Add implementation for Binary-Search-1#2470

Open
rishigoswamy wants to merge 1 commit intosuper30admin:masterfrom
rishigoswamy:master
Open

Add implementation for Binary-Search-1#2470
rishigoswamy wants to merge 1 commit intosuper30admin:masterfrom
rishigoswamy:master

Conversation

@rishigoswamy
Copy link

No description provided.

@super30admin
Copy link
Owner

Your solution for the rotated sorted array search problem is excellent. You have correctly implemented the binary search by checking which half is sorted and then adjusting the search range based on whether the target lies within the sorted half. The code is efficient and meets the required time and space complexities. The comments are helpful and demonstrate a good understanding of the approach.

One minor suggestion: In the condition if target >= nums[low] and target < nums[mid], you can use parentheses for clarity, although it is not strictly necessary due to operator precedence. For example, if (target >= nums[low]) and (target < nums[mid]) might be slightly more readable. However, this is a very small point and does not affect the correctness.

Overall, great job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants