← All problemsSign in

Krishna and Stacks

Krishna is playing with stacks. In the beginning of the game, he has an empty stack denoted by number '0'. The game consists of a series of steps. In the ith step of the game, he will choose an existing stack denoted by 'p', copy it (he will create a new copy of it leaving the old one as such) and perform one of the following actions: Action 1: Place a number 'i' on top of the new stack. Action

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