FastPrepSpecial Keyboard
Problems/Special Keyboard

Special Keyboard

Zomato / Eternal logoZomato / Eternal● MediumONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamples

Problem statement

You have a special keyboard with four keys:

  • Key 1 prints A on the screen.
  • Key 2 performs Ctrl-A and selects the whole screen.
  • Key 3 performs Ctrl-C and copies the current selection into a buffer.
  • Key 4 performs Ctrl-V and 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) → int

Examples

Example 1

n = 7return = 9

One 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
All Zomato / Eternal interview questionsSee Zomato / Eternal hiring insights
Saved
class Solution {
    public int maxAWithSpecialKeyboard(int n) {
      // write your code here
    }
}
Checking account…