a weighs 1, b weighs 2, ..., z weighs 26. The weight of a word is the sum of its letters' weights; for example, "bad" weighs 2 + 1 + 4 = 7.
Given integers length and total, return the lexicographically smallest word of length lowercase English letters whose weight is exactly total.length=4, total=30 → 'aabz'
1 + 1 + 2 + 26 = 30. To keep the start as small as possible, all the weight is pushed to the end.
length=2, total=2 → 'aa'
The only two-letter word with weight 2 is "aa".
length=3, total=78 → 'zzz'
length=4, total=30
'aabz'
Run checks the first 3 tests in your browser. Submit checks all 64 tests on the server, hidden ones included.