DEAD END lunchtime

Can somebody help where i am going wrong in problem dead end in lunch time november…
https://www.codechef.com/viewsolution/28012555https://www.codechef.com/viewsolution/28012555

1
4
1 3 5 8

Should give 3 but your solution gives 2

1 Like

why did you do

a[i]--; 

my approach is a bit similar to yours and i used a map to store positions
https://www.codechef.com/viewsolution/28010782
check this out :slight_smile:

Code is perfecly fine (a[i]–) what i thought but forgot to write else statement now i have corrected that in else if loop it should have been >=2 i did ==2 .Because i had a different appproach in my mind while iimplemented the different one…
Have a quick lookhttps://www.codechef.com/viewsolution/28031572