Skip to content

Complete binary search related problems#2456

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

Complete binary search related problems#2456
paridhimalviya wants to merge 1 commit intosuper30admin:masterfrom
paridhimalviya:master

Conversation

@paridhimalviya
Copy link

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:

  • The student has a good understanding of binary search and its application to rotated sorted arrays.
  • The code is well-commented and easy to follow.
  • The student has provided multiple solutions, showing a deep understanding of the problem.

Areas for Improvement:

  • The condition low < high in searchWithAConditionChange could miss some edge cases. It's better to stick with low <= high to ensure all cases are covered.
  • The student could benefit from more concise variable names (e.g., mid instead of midIndex if it were used).
  • The additional method searchWithAConditionChange is not necessary and could be confusing. It's better to focus on one correct solution.

@super30admin
Copy link
Owner

Strengths:

  • The student has a good understanding of binary search and its application to rotated sorted arrays.
  • The code is well-commented and easy to follow.
  • The student has considered edge cases and provided alternative methods for comparison.

Areas for Improvement:

  • The searchWithAConditionChange method seems unnecessary and could be removed to simplify the code.
  • The initialization and testing code (init()) should be separated from the core logic for better modularity.
  • The comments could be more concise and focused on the key insights rather than repeating the problem statement.

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