Skip to content

Binary Search problems list 1#2455

Open
rajyalakshmimannem wants to merge 3 commits intosuper30admin:masterfrom
rajyalakshmimannem:master
Open

Binary Search problems list 1#2455
rajyalakshmimannem wants to merge 3 commits intosuper30admin:masterfrom
rajyalakshmimannem:master

Conversation

@rajyalakshmimannem
Copy link

Binary-Search-1

Problem1

Search a 2D Matrix(https://leetcode.com/problems/search-a-2d-matrix/)

Problem2

Search in a Rotated Sorted Array (https://leetcode.com/problems/search-in-rotated-sorted-array/)

Problem3

Search in Infinite sorted array:

https://leetcode.com/problems/search-in-a-sorted-array-of-unknown-size/

Given a sorted array of unknown length and a number to search for, return the index of the number in the array. Accessing an element out of bounds throws exception. If the number occurs multiple times, return the index of any occurrence. If it isn’t present, return -1.

@super30admin
Copy link
Owner

  • Strengths:

    • Correct implementation of binary search for all three problems.
    • Good use of comments to explain the logic, especially in the rotated array problem.
    • Proper handling of edge cases, such as checking for null or empty matrix in the 2D matrix problem.
    • Efficient use of space and time complexity.
  • Areas for Improvement:

    • In the "SearchInRotatedArray" solution, the condition nums[mid] > target could be written as nums[mid] > target to be more consistent with the reference solution's style (though both are correct).
    • The comments in the "SearchInSortedArrayOfUnknownSize" and "Searcha2DMatrix" solutions could be expanded slightly to explain the logic, similar to the first solution.

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