Generate a String With Characters That Have Odd Counts - Problem
Given an integer n, return a string with n characters such that each character in the string occurs an odd number of times.
The returned string must contain only lowercase English letters. If there are multiple valid strings, return any of them.
Input & Output
Example 1 — Odd Length
$
Input:
n = 3
›
Output:
aaa
💡 Note:
String has 3 characters, character 'a' appears 3 times (odd count). Any single character repeated 3 times works.
Example 2 — Even Length
$
Input:
n = 4
›
Output:
aaab
💡 Note:
String has 4 characters, 'a' appears 3 times (odd), 'b' appears 1 time (odd). Both characters have odd counts.
Example 3 — Minimum Case
$
Input:
n = 1
›
Output:
a
💡 Note:
Single character string, 'a' appears 1 time (odd count). This is the smallest valid case.
Constraints
- 1 ≤ n ≤ 500
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code