← All problemsSign in

Cheap Thrills

Vinod is bored, so he decided to play a quick game. He has a sequence 'S' consisting of N integers and an empty array A. In each step Vinod removes either first or last number of sequence S and adds it at the end of the array A. This game continues till there are no more numbers left in S. In the end of the game, array A has N numbers. Now maximum of 2n-1 permutations of array A are possible depe

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start