Can someone point error in this code (BFRIEND)

https://www.codechef.com/viewsolution/29794977

Problem Name: BFRIEND, from last lunchtime

1
3 5 3 1
6 2 4

Bro it will fail this test case .
Your code’s output here will be 5 which is wrong . The correct answer is 3.

According to your code ,
You will start at 3rd floor go to 2nd floor again come to 3rd floor then go to 4th floor then reach 5th floor .
Time elapsed = 5 minutes

Right order ,
You will start at 3rd floor goto 4th floor then reach 5th floor .
Time elapsed = 3 minutes

Hope you understood your mistake :smile:

Thankyou @shlok_dhara for pointing out this test case :slight_smile:

1 Like