For the test case “586 g t t g P 593848644 t p t t t t p P 680232627 P 383101258…”, it is showing that my function is returning garbage value but when I ran it as custom test, the output was matching the expected output. Moderators, please look into it!
Correct test case in testing, garbage on submitting for test case "586 g t t g P 593848644 t p t t t t p P 680232627 P 383101258..."
Yep. I’m also facing the same problem. I’m using Python2.
Yes,I am also face the same issue.I am using C++
the stack which u declare as globle clear it after the program exection
For this test case, there are two things because of which this test case fails:
- not clearing global variables
- using top or pop functions on empty stack
i) When the top of stack is less than min Element you have to return min Element.
( as u would have stored it as stack.push(2*x - current min element) )
ii) Empty stack in the constructor and reset min Element to -1;
iii) Before returning the min Element or top of stack always check if stack is not empty.
iv) Check if stack is empty after poping and set min Element to -1 in that case.
Just resize the array as zero size in the constructor, it would work fine, idk maybe it’s intializing it with some garbage values!
Are you initializing min variable with INT_MAX. If yes do not initialize it, rather use a separate condition in push function like this:
It worked for me.
after declaration of stack ,empty the stack in constructor as shown .it worked for me…happy coding