Importance of time


please point out my mistake

hi @manmeetkahlon

why your are using stack ?
use should use queue here
as insertion at back and deletion take place at front end

your mistake
input is
5
5 4 2 3 1
5 2 1 4 3

but in stack it is stored in reverse order
c
alling => 1 2 3 4 5
ideal => 3 4 1 2 5

and now you are comparing 1 and 3
that’s why your output is coming wrong

you can take help from this code if needed

@asaurabh_26 okayy Thankyou

1 Like