Why my code is giving wrong answer??
BUY AND SELL- Doubt
hi, I have gone through your code here’s what you have missed
- in update function it should be while(val<max1) instead of while(val<=max1)
- also, you have to maintain count map which will maintain the frequency of each element present so that in case of freq=0 and you decrement the element so in that case you dont have to update
I have fixed your code have a look:
In case of any doubt feel free to ask
if you got the answer mark your doubt as resoved