Strings of Numbers Problem Statement
You are given two integers 'N' and 'K'. Consider a set 'X' of all possible strings of 'N' number of digits where all strings only contain digits ranging from 0 to 'K' inclusive. Your task is to determine a string of minimal length such that it includes every string from set 'X' as one of its substrings.
Example:
Input:
N = 2, K = 2
Output:
'X' = {00, 01, 02, 10, 11, 12, 20, 21, 22}
Explanation:
Find a string that contains all possible combinations of 2-digit numbers with digits from 0 to 2.
Constraints:
- 1 ≤ T ≤ 5
- 1 ≤ N ≤ 4
- 0 ≤ K ≤ 9
- Time Limit: 1 sec
Input:
Each test case contains two integers 'N' and 'K' denoting the number of digits in each number and the maximum value of digits respectively.
Output:
For each test case, print 1 if your solution contains all strings from the set, otherwise print 0.
Note:
- If multiple solutions are possible, any one can be printed.
- No need to handle input or output yourself, just implement the required function.
Be the first one to answer
Add answer anonymously...
Top TCS Software Developer interview questions & answers
Popular interview questions of Software Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app