|
| 1 | +<h2><a href="https://leetcode.com/problems/2-keys-keyboard">650. 2 Keys Keyboard</a></h2><h3>Medium</h3><hr><p>There is only one character <code>'A'</code> on the screen of a notepad. You can perform one of two operations on this notepad for each step:</p> |
| 2 | + |
| 3 | +<ul> |
| 4 | + <li>Copy All: You can copy all the characters present on the screen (a partial copy is not allowed).</li> |
| 5 | + <li>Paste: You can paste the characters which are copied last time.</li> |
| 6 | +</ul> |
| 7 | + |
| 8 | +<p>Given an integer <code>n</code>, return <em>the minimum number of operations to get the character</em> <code>'A'</code> <em>exactly</em> <code>n</code> <em>times on the screen</em>.</p> |
| 9 | + |
| 10 | +<p> </p> |
| 11 | +<p><strong class="example">Example 1:</strong></p> |
| 12 | + |
| 13 | +<pre> |
| 14 | +<strong>Input:</strong> n = 3 |
| 15 | +<strong>Output:</strong> 3 |
| 16 | +<strong>Explanation:</strong> Initially, we have one character 'A'. |
| 17 | +In step 1, we use Copy All operation. |
| 18 | +In step 2, we use Paste operation to get 'AA'. |
| 19 | +In step 3, we use Paste operation to get 'AAA'. |
| 20 | +</pre> |
| 21 | + |
| 22 | +<p><strong class="example">Example 2:</strong></p> |
| 23 | + |
| 24 | +<pre> |
| 25 | +<strong>Input:</strong> n = 1 |
| 26 | +<strong>Output:</strong> 0 |
| 27 | +</pre> |
| 28 | + |
| 29 | +<p> </p> |
| 30 | +<p><strong>Constraints:</strong></p> |
| 31 | + |
| 32 | +<ul> |
| 33 | + <li><code>1 <= n <= 1000</code></li> |
| 34 | +</ul> |
0 commit comments