java.lang.Object
g0901_1000.s0984_string_without_aaa_or_bbb.Solution

public class Solution extends Object
984 - String Without AAA or BBB.<p>Medium</p> <p>Given two integers <code>a</code> and <code>b</code>, return <strong>any</strong> string <code>s</code> such that:</p> <ul> <li><code>s</code> has length <code>a + b</code> and contains exactly <code>a</code> <code>'a'</code> letters, and exactly <code>b</code> <code>'b'</code> letters,</li> <li>The substring <code>'aaa'</code> does not occur in <code>s</code>, and</li> <li>The substring <code>'bbb'</code> does not occur in <code>s</code>.</li> </ul> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> a = 1, b = 2</p> <p><strong>Output:</strong> &ldquo;abb&rdquo;</p> <p><strong>Explanation:</strong> &ldquo;abb&rdquo;, &ldquo;bab&rdquo; and &ldquo;bba&rdquo; are all correct answers.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> a = 4, b = 1</p> <p><strong>Output:</strong> &ldquo;aabaa&rdquo;</p> <p><strong>Constraints:</strong></p> <ul> <li><code>0 <= a, b <= 100</code></li> <li>It is guaranteed such an <code>s</code> exists for the given <code>a</code> and <code>b</code>.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • strWithout3a3b

      public String strWithout3a3b(int a, int b)