Generate a String With Characters That Have Odd Counts Problem
Generate a String With Characters That Have Odd Counts Problem — ExecCode Easy DSA Practice
Solve the Generate a String With Characters That Have Odd Counts problem on ExecCode. Free online easy DSA practice in String. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given an integer n, return a string with n characters such that each character in such string occurs an odd number of times . Your task is to if there are multiples valid strings, return any of them. The returned string must contain only lowercase English letters.
Examples
Input {"n": 250}; Output aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab. Input {"n": 3}; Output aaa. Input {"n": 100}; Output aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab
Constraints
1 <= n <= 500
Practice Generate a String With Characters That Have Odd Counts free on ExecCode. Browse DSA problems, topic map, and placement guides.