Problem Submissions Solution

Find the String

Difficulty: Hard

Acceptance: %

Points: 40.00

Given two integers N and K, the task is to find the string S of minimum length such that it contains all possible strings of size N as a substring. The characters of the string should be from integers ranging from 0 to K-1.  Complete the function findString( ) which takes the integer N and the integer K as input parameters and returns the string.

Note: In case of multiple answers, return any string of minimum length which satisfies above condition. The driver will print the length of the string. In case of wrong answer it will print -1.

Topics

Companies

Articles

Examples:

Expected Time Complexity: O(KNK)

Expected Space Complexity: O(KNN)

Constraints:
  • 1 <= N <= 4
  • 1 < K < 10
  • 1 < KNN < 10^6
Companies:
Google
Topics:
String
Locked Content
Access Restricted: Please Login to access the code editor and test cases.