2 Keys Keyboard

There is only one character 'A' on the screen of a notepad. You can perform two operations: copy all characters on the screen or paste the last copied characters. Given an integer n, return the minimum number of operations to display exactly n 'A's on the screen.

Constraints

  • 1 <= n <= 1000
Saving… · 3 lines
class Solution:
def minSteps(self, n: int) -> int:

Console

Click Run to execute sample tests.