leetcode icon indicating copy to clipboard operation
leetcode copied to clipboard

Bug Report for find-minimum-in-rotated-sorted-array

Open zerobear8530032 opened this issue 2 months ago • 1 comments

Bug Report for https://neetcode.io/problems/find-minimum-in-rotated-sorted-array

Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.

there is no validation of test cases created by user i was trying to solve the find-minimum-in-rotated-sorted-array and i by mistake created completely descending order array it accepted the test case

zerobear8530032 avatar Oct 07 '25 12:10 zerobear8530032

Can you share the code?

Srihari2222 avatar Oct 08 '25 00:10 Srihari2222

Can you share the code?

the problem is not inside the code its inside the custom test case creation is not validating correctly :

here is my code : // this is a simple binary search to find the pivote of the sorted array class Solution { public int findMin(int[] nums) { int s = 0, e = nums.length - 1;

while(s < e){
    int m = s + (e - s) / 2;
    if(nums[m] > nums[e]){ 
        // pivot is to the right of m
        s = m + 1;
    } else { 
        // pivot is at m or to the left
        e = m;
    }
}   
// s == e is the minimum
return nums[s];
}

}

now when i use test cases : case 1 : [4,5,0,1,2,3] case 2 : [4,5,0,1,2,3] case 3 :// in correct test case 3 should not be allowed to be created by user [5,4,3,2,1,0]

// this case 3 should not be allowed to be created because if the array is in ascending order by default and rotate no matter how many times it will never become a completely descendig order array which lead to wrong output for people : inital array according to questions : [0,1,2,3,4,5] rotation 1 : [5,0,1,2,3,4]

rotation 2: [4,5,0,1,2,3]

rotation 3: [3,4,5,0,1,2]

rotation 4: [2,3,4,5,0,1]

rotation 5: [1,2,3,4,5,0]

rotation 6: [0,1,2,3,4,5] back to initial array it never becomes the custom array case which was [5,4,3,2,1,0 ] created as test case so it should validate the creation of custom test cases it is correct accoding to the questions or not

hope this explanaition will help you

zerobear8530032 avatar Nov 18 '25 19:11 zerobear8530032