Problem Statement
Recently all cars in NJ had a specific pattern of digits and letters for their license plate numbers. For example, the license plate number "UG830H" follows the pattern "LLDDDL", where 'L' stands for letter, and 'D' stands for digit. 17,576,000 distinct license plate numbers can be generated using this format. As the population and the number of cars grows, new formats appear. For example, the new format in NJ is "LLLDDL" (as in "MEL87H"). The new format will be able to number 45,697,600 cars. Assume that plates are assigned in lexicographic order (the order they would appear in a dictionary. i.e. "AAA" comes before "AAB" and "AA1" comes before "AA7"). For practical purposes it is important to know how many plates are available for further assignment at each moment in time.
Your task is, given a
For example, given the
Definition
- Class:
- Plates
- Method:
- numLeft
- Parameters:
- String
- Returns:
- long
- Method signature:
- long numLeft(String plateNum)
- (be sure your method is public)
Notes
- We assume that only upper-case letters and digits can be used in plate numbers.
- Digit 0 (zero) should be treated like any other digit. That is, the plate number can start with 0, if it starts with a digit.
- The 64 bit datatype in C++ is long long.
Constraints
- plateNum contains between 3 and 8 characters inclusive
- each character of plateNum is a digit ('0'-'9') or an upper-case letter ('A'-'Z')
Examples
"222"
Returns: 777
plates are made of three digits starting from "000" and ending with "999".
"TA4KA"
Returns: 1227355
"KAPETA"
Returns: 189835177
"MAPA3M"
Returns: 63875149
"ZZZZZ"
Returns: 0
"AAAAAAAA"
Returns: 208827064575
"ZZA"
Returns: 25
"ZAA"
Returns: 675
"ZAZ"
Returns: 650
"AZZ"
Returns: 16900
"AZA"
Returns: 16925
"AAZ"
Returns: 17550
"Z9Z9"
Returns: 0
"FEB29"
Returns: 1409070
"AAAZZZZZ"
Returns: 208815183200
"ZZAAAAAA"
Returns: 308915775
"ZAAAAAAA"
Returns: 8031810175
"12345678"
Returns: 87654321
"00000000"
Returns: 99999999
"A0A0A0A0"
Returns: 4569759999
"HMM333HA"
Returns: 8463294709
"D43"
Returns: 2256
"KAPETA"
Returns: 189835177
"AAA"
Returns: 17575
"AAAAAAAA"
Returns: 208827064575
"222"
Returns: 777
"MAPA3M"
Returns: 63875149
"AK51DDK"
Returns: 1169663107
"H3AB5RZ0"
Returns: 8545345129
"TA47KA"
Returns: 12271167
"AAAZ97"
Returns: 45695002
"ZZZZZZZZ"
Returns: 0
"KAPETA4B"
Returns: 49357146174
"BBBBBBBB"
Returns: 200473981992
"AMBROSE"
Returns: 7888467959
"Z00Z0AB"
Returns: 17406998
"AAAABAAA"
Returns: 208827046999
"AAAAAABA"
Returns: 208827064549