Maximum number of characters using keystrokes A, Ctrl+A, Ctrl+C and Ctrl+V

前端 未结 14 1508
忘掉有多难
忘掉有多难 2020-12-07 07:03

This is an interview question from google. I am not able to solve it by myself. Can somebody shed some light?

Write a program to print the sequence of keystrokes suc

14条回答
  •  我在风中等你
    2020-12-07 07:13

    If N key Strokes are allowed, then the result is N-3.

    A's -> N-3

    CTRL+A -> Selecting those N Characters :+1

    CTRL+C -> Copying those N Characters :+1

    Ctrl+V -> Pasting the N Characters. :+1 i.e., (Since we have selected the whole characters using CTRL+A) Replacing these existing N-3 characters with the copied N-3 Characters(which is overriding the same characters) and the result is N-3.

提交回复
热议问题