← All problemsSign in

2202. Maximize the Topmost Element After K Moves

LeetCodeArrayGreedyOpen on judge ↗

You are given a 0-indexed integer array nums representing the contents of a pile, where nums[0] is the topmost element of the pile. In one move, you can perform either of the following: - If the pile is not empty, remove the topmost element of the pile. - If there are one or more removed elements, add any one of them back onto the pile. This element becomes the new topmost element. You are als

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