Problem · Math
Nth License Plate
Learn this problemProblem statement
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) → StringExamples
Example 1
n = 3return = "00002"The first three plates are 00000, 00001, and 00002.
Example 2
n = 100001return = "0000A"The first 100000 positions contain five digits, so the next plate begins the one-letter group.
Constraints
1 <= n <= 19244736