Tap here to switch tabs
Problem
Submissions

Problem: 2 Keys Keyboard

med
30 min
Try to solve the 2 Keys Keyboard problem.

Statement

You start with a text editor that initially contains a single character 'A'. You can perform only the following operations.

Copy All: copy the entire current content to the clipboard.
Paste: append the clipboard content to the current content.

Given an integer n, return the minimum number of operations needed to end with exactly n characters 'A' in the editor.

Constraints:

  • 1≤1 \leq n ≤103\leq 10^3

⋮
Tap here to switch tabs
Problem
Submissions

Problem: 2 Keys Keyboard

med
30 min
Try to solve the 2 Keys Keyboard problem.

Statement

You start with a text editor that initially contains a single character 'A'. You can perform only the following operations.

Copy All: copy the entire current content to the clipboard.
Paste: append the clipboard content to the current content.

Given an integer n, return the minimum number of operations needed to end with exactly n characters 'A' in the editor.

Constraints:

  • 1≤1 \leq n ≤103\leq 10^3