• You can make ‘B’ from ‘S’ by removing some characters and rearranging some characters zero or more times.
• Length of ‘S’ must be as minimum as possible.
Testcases are generated such that a substring always exists and is unique.
A = ninjas, B = sin
All possible substrings with which 'B' can be created are
"ninjas", "injas".
Hence the substring with minimum length is "injas".
The first line contains two space-separated strings ‘A’ and ‘B’.
Print the substring with minimum length.
You do not need to print anything, it has already been taken care of. Just implement the given function.
The idea here is to generate all possible substrings of “A” and check if it contains all characters of “B” or not.
The idea here is to use the sliding window technique. We will maintain two pointers left and right to get the minimum substring.