650. 2 Keys Keyboard Medium

@problem@discussion
#Math#Dynamic Programming



1/**
2 * [650] 2 Keys Keyboard
3 *
4 * There is only one character 'A' on the screen of a notepad. You can perform one of two operations on this notepad for each step:
5 * 
6 * 	Copy All: You can copy all the characters present on the screen (a partial copy is not allowed).
7 * 	Paste: You can paste the characters which are copied last time.
8 * 
9 * Given an integer n, return the minimum number of operations to get the character 'A' exactly n times on the screen.
10 *  
11 * Example 1:
12 * 
13 * Input: n = 3
14 * Output: 3
15 * Explanation: Initially, we have one character 'A'.
16 * In step 1, we use Copy All operation.
17 * In step 2, we use Paste operation to get 'AA'.
18 * In step 3, we use Paste operation to get 'AAA'.
19 * 
20 * Example 2:
21 * 
22 * Input: n = 1
23 * Output: 0
24 * 
25 *  
26 * Constraints:
27 * 
28 * 	1 <= n <= 1000
29 * 
30 */
31pub struct Solution {}
32
33// problem: https://leetcode.com/problems/2-keys-keyboard/
34// discuss: https://leetcode.com/problems/2-keys-keyboard/discuss/?currentPage=1&orderBy=most_votes&query=
35
36// submission codes start here
37
38impl Solution {
39    pub fn min_steps(n: i32) -> i32 {
40        0
41    }
42}
43
44// submission codes end
45
46#[cfg(test)]
47mod tests {
48    use super::*;
49
50    #[test]
51    fn test_650() {
52    }
53}
54


Back
© 2025 bowen.ge All Rights Reserved.