CT088

Number Letter Counts

EasyAcceptance: 0.0%

If the numbers 1 to 5 are written out in words: one, two, three, four, five, there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. If all the numbers from 1 to n (inclusive) were written out in words, how many letters would be used? Use British usage: 'and' is used after hundreds (e.g. 'three hundred and forty-two'). Do not count spaces or hyphens.

Example 1:

Input: 5
Output: 19

Example 2:

Input: 1000
Output: 21124

Example 3:

Input: 100
Output: 864

Constraints:

1 <= n <= 1000

Tags:

math string-processing numbers
Loading...
Test Cases:No test cases
No test cases available.