Reported November 2024
Googlemath

Nth License Plate

Reported by candidates from Google's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Google OA. Under 2s to a working solution.
Founder's read

Google, November 2024. The Nth License Plate problem looks like a string puzzle, but it's really a mixed-radix conversion in disguise. You have six groups of plates, each group with 10^(5-L) * 26^L entries, and you need to land on one exact plate without generating them all. If you've got an OA invite and 48 hours, this is a good one to nail down cold. The math is short once you see it. If you blank on the live assessment, StealthCoder runs invisibly as a safety net and hands you the structure while you type.

The problem

License plates are five-character strings arranged in six consecutive groups. In group L, where 0 <= L <= 5, a plate has 5 - L leading decimal digits followed by L uppercase English letters.
Within a group, the numeric part varies fastest from all zeroes to all nines. The letter suffix then advances in ordinary base-26 order from all A characters to all Z characters. For example, the sequence starts with 00000 through 99999, then 0000A through 9999A, then 0000B, and eventually ends at ZZZZZ.
Given the one-indexed position n, return the corresponding license plate.

Function
nthLicensePlate(n: int) → String

Examples
Example 1
n = 3
return = "00002"
The first three plates are 00000, 00001, and 00002.
Example 2
n = 100001
return = "0000A"
The first 100000 positions contain five digits, so the next plate begins the one-letter group.

Constraints
1 <= n <= 19244736

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick: subtract group sizes until n fits. Convert n to zero-indexed first. Group L has 10^(5-L) * 26^L plates. Walk L from 0 to 5, and if the index is at least the group size, subtract it and move on. Once you're inside a group, the digits vary fastest, so split the index: digitPart = idx % 10^(5-L), letterPart = idx / 10^(5-L). Pad digitPart with zeros to width 5-L. Convert letterPart to base 26 with A as 0, padded to L letters. The common pitfall is off-by-one from one-indexing, and forgetting that letters are fixed width, so A is 'AAA' style padding, not a bare 'A'. Another trap is writing the letter order backwards. Check Example 2: n=100001 gives idx 100000, subtract 100000, then group 1 idx 0 gives 0000A. StealthCoder is your hedge if the arithmetic slips under pressure. The whole solution runs in constant time.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Nth License Plate cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Google's OA.

Google reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Nth License Plate FAQ

What's the trick to Nth License Plate?+

Treat it as a mixed-radix lookup. Convert n to zero-indexed, subtract each group's size (10^(5-L) * 26^L) until the index fits, then split the remainder with modulo and division into a digit part and a letter part. No generation needed.

How hard is this problem really?+

Easy on ideas, annoying on details. There's no fancy data structure. The risk is off-by-one errors, padding mistakes, and mixing up which part varies fastest. If you test both examples by hand, you'll catch most bugs.

Do I need to loop through all plates?+

No. The max n is 19244736, so brute force might pass, but it's wasteful and risky. Group sizes let you jump straight to the right group in at most six steps, then compute the plate directly.

How do I convert the letter part correctly?+

Divide the in-group index by 10^(5-L) to get the letter rank. Then convert that rank to base 26, with A=0 through Z=25, producing exactly L letters. Pad with leading A characters. Letters come after digits in the plate string.

How should I prep for this in 48 hours?+

Practice base conversion and cumulative range subtraction on small cases. Write the group size formula, hand-trace n=3 and n=100001, then code it. Also test boundaries: n=1, the last plate of group 0, and n=19244736 should return ZZZZZ.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Google.

OA at Google?
Invisible during screen share
Get it