java.lang.Object
g1301_1400.s1374_generate_a_string_with_characters_that_have_odd_counts.Solution

public class Solution extends Object
1374 - Generate a String With Characters That Have Odd Counts.<p>Easy</p> <p>Given an integer <code>n</code>, <em>return a string with <code>n</code> characters such that each character in such string occurs <strong>an odd number of times</strong></em>.</p> <p>The returned string must contain only lowercase English letters. If there are multiples valid strings, return <strong>any</strong> of them.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> n = 4</p> <p><strong>Output:</strong> &ldquo;pppz&rdquo;</p> <p><strong>Explanation:</strong> &ldquo;pppz&rdquo; is a valid string since the character &lsquo;p&rsquo; occurs three times and the character &lsquo;z&rsquo; occurs once. Note that there are many other valid strings such as &ldquo;ohhh&rdquo; and &ldquo;love&rdquo;.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> n = 2</p> <p><strong>Output:</strong> &ldquo;xy&rdquo;</p> <p><strong>Explanation:</strong> &ldquo;xy&rdquo; is a valid string since the characters &lsquo;x&rsquo; and &lsquo;y&rsquo; occur once. Note that there are many other valid strings such as &ldquo;ag&rdquo; and &ldquo;ur&rdquo;.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> n = 7</p> <p><strong>Output:</strong> &ldquo;holasss&rdquo;</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= n <= 500</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • generateTheString

      public String generateTheString(int n)