Ctrl K

Every Letter an Odd Number of Times

Easy
You are given a number length. Build a string of length lowercase English letters in which **every** letter that appears does so an odd number of times. Many strings qualify, so return the lexicographically smallest one (the one that would come first in a dictionary).
Example 1
length=5 → 'aaaaa'

The length is odd, so five as will do: the letter occurs 5 times.

Example 2
length=6 → 'aaaaab'

Six as will not do, since 6 is even. The best option is five as followed by one b.

Example 3
length=2 → 'ab'
Constraints
  • 1 ≤ length ≤ 500
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsValue of a Roman Numeral EasyShared Start of Words EasyBracket Balance EasyWhere the Fragment Starts EasyLength of the Final Word Easy
loading Python…
Input
length=5
Expected
'aaaaa'

Run checks the first 3 tests in your browser. Submit checks all 61 tests on the server, hidden ones included.