Special Keyboard
Updated
Problem statement
You have a special keyboard with four keys:
- Key 1 prints
Aon the screen. - Key 2 performs
Ctrl-Aand selects the whole screen. - Key 3 performs
Ctrl-Cand copies the current selection into a buffer. - Key 4 performs
Ctrl-Vand appends the buffer to the screen.
Given an integer n, return the maximum number of A characters that can be produced using exactly n key presses.
Function
maxAWithSpecialKeyboard(n: int) → intExamples
Example 1
n = 7return = 9One optimal sequence is A, A, A, Ctrl-A, Ctrl-C, Ctrl-V, Ctrl-V, producing 9 copies of A.
More Zomato / Eternal interview questions
- Find the Two Unique NumbersONSITE INTERVIEW · Seen Oct 2026
- Flipping MatrixONSITE INTERVIEW · Seen Oct 2026
- Jump Game IVONSITE INTERVIEW · Seen Oct 2026
- LFU CacheONSITE INTERVIEW · Seen Aug 2026
- Detonate the Maximum BombsPHONE SCREEN · Seen Dec 2026
- Friend Circles and Redundant ConnectionsPHONE SCREEN · Seen Sep 2026
- Maximum Production Within PowerOA · Seen Jul 2026
- Rearrange Songs by AuthorOA · Seen Jul 2026
- Robot Warehouse OptimizationOA · Seen Jul 2026
Similar questions at other companies
- Maximum Sum with K-Element SkippingPhonePe · ONSITE INTERVIEWPhonePe interview questions
- Assign Escalations to TeamsAmazon · ONSITE INTERVIEW
- Collatz Conjecture with Shared MemoizationBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Count Complete Tic-Tac-Toe GamesDecagon · PHONE SCREEN · ONSITE INTERVIEWDecagon interview questions
- Distinct Subset SumsGoogle · ONSITE INTERVIEWGoogle interview questions
- Count Subsets With a Target SumSafe Security · ONSITE INTERVIEW
- Minimum Coins for a TargetInfosys · ONSITE INTERVIEWInfosys interview questions
- Knight Probability in ChessboardGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
- Maximum Subarray Sum with One DeletionOracle · ONSITE INTERVIEWOracle interview questions
- Best Time to Buy and Sell Stock IIKotak Mahindra Bank · ONSITE INTERVIEWKotak Mahindra Bank interview questions