Test case no 2 is failing for the following code
int ref=0;
int[] ans=new int[prices.length];
for(int i=0;i<prices.length;i++) {
if(prices[i]>ref) {
stack.push(prices[i]);
ref=prices[i];
}else {
while(!stack.isEmpty()) {
stack.pop();
}
stack.push(prices[i]);
ref=prices[i];
}
ans[i]=stack.size();
}
return ans;
1 test case failing
you will get a wrong answer for the test case:
Input:
5
1 11 6 16 13
Correct output:
1 2 1 4 1 END
Your Output:
1 2 1 2 1 END