Company: Amazon Ml school_3aug
Difficulty: medium
Notepad Editor Problem Description After years of coding on your text editor, you began to wonder about a simple problem. Initially, you have 1 line of text. And, you want A copies of that line on the text editor. You can use three operations: Select X lines from the top which costs X energy. Use CTRL + A to select all the lines present in the text editor which costs 1 energy. Suppose, you already have Y lines selected from the previous operation, you can use those Y lines for 0 energy again. After selecting, copying and pasting (both combined) cost 1 energy. Since, you are running low on coffee, find out the minimum energy needed to have A lines of text on the text editor. Examples Example 1: Input: A = 3 Output: 3 Explanation: We can simply copy 1 first line then paste 2 times. Total cost is 3 energy. Example 2: Input: A = 6 Output: 5 Explanation: We can copy first line then paste. Then, copy all the lines and paste twice. This way we can have 6 lines in 5 energy. It can be proved th