Trains the technique from
LeetCode 6502 Keys KeyboardThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A sheet starts with a single mark on it and the clipboard empty. Two keys are available:
Return the fewest key presses that leave exactly n marks on the sheet.
Example 1
Copy and paste once reaches two marks in two presses, then copy and paste twice triples that to six in three more. Five presses in all, which is two and three added together.
Example 2
Copy the single mark, then paste it once.
Example 3
Three presses reach three marks, and three more triple that to nine.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def min_steps(n: int) -> int:public int minSteps(int n)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.