Skip to content

Binary search2 dec25#2286

Open
sujaygijre wants to merge 6 commits intosuper30admin:masterfrom
sujaygijre:BinarySearch2-Dec25
Open

Binary search2 dec25#2286
sujaygijre wants to merge 6 commits intosuper30admin:masterfrom
sujaygijre:BinarySearch2-Dec25

Conversation

@sujaygijre
Copy link
Copy Markdown

No description provided.

sujay sudarshan gijre and others added 2 commits September 17, 2020 20:05
@super30admin
Copy link
Copy Markdown
Owner

  • The solution does not address the correct problem (finding the range of a target in a sorted array). Please ensure you understand the problem requirements before coding.
  • The recursive approach, while correct for the problem it solves, is less space-efficient than an iterative approach. Consider using iteration to reduce space complexity.
  • Adding comments to explain the logic would improve code readability and maintainability.
  • The variable names are clear, but the function name bsearch could be more descriptive (e.g., findMinInRotatedArray).
  • The base cases and edge cases are handled well, but the logic is not applicable to the problem of finding the target range.

sujay sudarshan gijre and others added 4 commits December 26, 2025 08:16
public:
    int findMin(vector<int>& nums) {
        int left = 0;
        int right = nums.size()-1;
        if (nums[left] < nums[right]) {
            return nums[left];
        }
        while (left < right) {
            int mid = left + (right-left)/2;
            if (nums[mid] < nums[right]) {
                // because the array is rotated more probablity
                // of finding the element in the second half
                // right = mid because the mid could be the smallest
                right = mid;
            } else {
                left = mid+1;
            }
        }
        retur
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