#1374
Generate a String With Characters That Have Odd Counts
newbie · 260 · lc easy +19 · failed · 78.5% accepted · 527 likes · top 90%
Description
Given the integer n, produce any string of length n using only lowercase English letters such that every distinct character in the string appears an odd number of times. Return any valid answer.
Example 1:
Input: n = 4
Output: "pppz"
Explanation: "pppz" is a valid string since the character 'p' occurs three times and the character 'z' occurs once. Note that there are many other valid strings such as "ohhh" and "love".
Example 2:
Input: n = 2
Output: "xy"
Explanation: "xy" is a valid string since the characters 'x' and 'y' occur once. Note that there are many other valid strings such as "ag" and "ur".
Example 3:
Input: n = 7
Output: "holasss"
Code
1
2
3