• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
November 17, 2023 |1.4K Views
PROBLEM OF THE DAY : 16/11/2023 | Better String
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Karan Mashru. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of String but also build up problem-solving skills.

In this problem, we are 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.  

Example :

Input:
N = 2, K = 2
Output: 
00110

Explanation: 
Allowed characters are from 0 to k-1 (i.e., 0 and 1).
There are 4 strings possible of size N=2 (i.e. "00", "01", "10", "11") "00110" contains all possible strings as a substring. It also has a minimum length.

Give the problem a try before going through the video. All the best!!!
Problem Link:  https://practice.geeksforgeeks.org/problems/find-the-string/1
Solution Link:  https://ide.geeksforgeeks.org/online-cpp-compiler/7dc59201-28d6-4393-a705-a28792502673