{"id":"458469f5-72c4-46be-bed3-f300ed33235d","name":"2 Key Keyboard","description":"1. You are given a number N.\r\n2. You have to print exactly N number of 'X' on a notepad by performing the minimum number of operations.\r\n3. Operations allowed are - \r\n copyAll -> You can copy all the characters present on the notepad.\r\n Paste -> You can paste the last copied characters.\r\n4. You have to find the minimum number of operations to get N 'X'.\r\n\r\nNote -> Initially, one 'X' is present on the screen.","inputFormat":"A number","outputFormat":"Check the sample output and question video.","constraints":"1 <= N <= 1000","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static int solution(int n) {\r\n\t\t//write your code here\r\n\t\t\r\n\t\treturn 0;\r\n\t}\r\n\t\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tint n = scn.nextInt();\r\n\t\tSystem.out.println(solution(n));\r\n\t}\r\n\r\n}"},"node":{"code":""},"ruby":{"code":""},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"3","sampleOutput":"3\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"8d8ab01b-f102-4543-973a-69f3c57119ce","name":"2 Key Keyboard","slug":"2-key-keyboard","type":1}],"next":{"id":"b3ee4f4e-3f27-451e-b230-8621d997f3cc","name":"4 Key Keyboard","type":1,"slug":"4-key-keyboard"},"prev":{"id":"0ed79e40-48be-4fe9-88a0-ac7a3d2bf3e8","name":"Word Wrap","type":1,"slug":"word-wrap"}}}

2 Key Keyboard

1. You are given a number N. 2. You have to print exactly N number of 'X' on a notepad by performing the minimum number of operations. 3. Operations allowed are - copyAll -> You can copy all the characters present on the notepad. Paste -> You can paste the last copied characters. 4. You have to find the minimum number of operations to get N 'X'. Note -> Initially, one 'X' is present on the screen.

{"id":"458469f5-72c4-46be-bed3-f300ed33235d","name":"2 Key Keyboard","description":"1. You are given a number N.\r\n2. You have to print exactly N number of 'X' on a notepad by performing the minimum number of operations.\r\n3. Operations allowed are - \r\n copyAll -> You can copy all the characters present on the notepad.\r\n Paste -> You can paste the last copied characters.\r\n4. You have to find the minimum number of operations to get N 'X'.\r\n\r\nNote -> Initially, one 'X' is present on the screen.","inputFormat":"A number","outputFormat":"Check the sample output and question video.","constraints":"1 <= N <= 1000","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static int solution(int n) {\r\n\t\t//write your code here\r\n\t\t\r\n\t\treturn 0;\r\n\t}\r\n\t\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tint n = scn.nextInt();\r\n\t\tSystem.out.println(solution(n));\r\n\t}\r\n\r\n}"},"node":{"code":""},"ruby":{"code":""},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"3","sampleOutput":"3\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"8d8ab01b-f102-4543-973a-69f3c57119ce","name":"2 Key Keyboard","slug":"2-key-keyboard","type":1}],"next":{"id":"b3ee4f4e-3f27-451e-b230-8621d997f3cc","name":"4 Key Keyboard","type":1,"slug":"4-key-keyboard"},"prev":{"id":"0ed79e40-48be-4fe9-88a0-ac7a3d2bf3e8","name":"Word Wrap","type":1,"slug":"word-wrap"}}}
plane

Editor


Loading...

2 Key Keyboard

medium

1. You are given a number N. 2. You have to print exactly N number of 'X' on a notepad by performing the minimum number of operations. 3. Operations allowed are - copyAll -> You can copy all the characters present on the notepad. Paste -> You can paste the last copied characters. 4. You have to find the minimum number of operations to get N 'X'. Note -> Initially, one 'X' is present on the screen.

Constraints

1 <= N <= 1000

Format

Input

A number

Output

Check the sample output and question video.

Example

Sample Input

3

Sample Output

3

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode