bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
Medium1-D Dynamic ProgrammingLC 651

4 Keys Keyboard

Imagine you have a special keyboard with the following keys: A: Print one 'A' on the screen. Ctrl-A: Select the whole screen. Ctrl-C: Copy selection to buffer. Ctrl-V: Print buffer on screen appending it after what has already been printed. Given an integer n, return the maximum number of 'A' you can print on the screen with at most n presses on the keys.

Asked at 2 companies
GoogleMicrosoft
Hints
  • 1.Think about which data structure fits best
  • 2.Consider the time complexity of your approach
  • 3.Look for patterns in the constraints
LeetCode