title: Print all possible strings of length k formed from set of n characters without repetitive structure
body: <blockquote>
    <p><strong>Print all possible strings of length k formed from set of n characters</strong> is a common question and already have <a href="https://www.geeksforgeeks.org/print-all-combinations-of-given-length/" rel="nofollow noreferrer">solution</a>.</p>
  </blockquote>
  
  <p>However, I hope to know</p>
  
  <blockquote>
    <p><strong>Question</strong>: Is there any way to Print all possible strings without repetitive structure ?</p>
  </blockquote>
  
  <h3>Repetitive Structure Examples [k = 3, n = {a, b, c}]:</h3>
  
  <ol>
  <li>AAA = BBB = CCC</li>
  <li>ABB = ACC = BAA = BCC = CAA = CBB</li>
  <li>ABC = ACB = BAC = BCA = CAB = CBA</li>
  <li>ABA = ACA = BAB = BCB = CAC = CBC</li>
  <li>AAB = AAC = BBA = BBC = CCA = CCB</li>
  </ol>
  
  <p>For Example:</p>
  
  <p>Input: 
  <code>k=3</code>, <code>n={a,b,c}</code></p>
  
  <p>Output: </p>
  
  <pre><code>aaa
  aab
  aba
  abb
  abc
  </code></pre>
  
  <p>For the complexity requirement: It should not greater than <code>O(n^k)</code>.</p>