Available question text
Given an array where nums[0] is the top of a pile and in each move you may either pop the top or push back any previously removed element, compute the maximum possible top element after exactly k moves (or -1 if you cannot end with a non-empty pile). The core challenge is choosing which prefix elements to remove and which removed element (if any) to restore — only the first min(n, k+1) elements matter, with special-edge cases when n=1 or k is small.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 2202. Maximize the Topmost Element After K Moves
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source