You can convert the list of valid words into any data structure you desire.
If the sequence of number = 2633, and the list of valid words = [ride, used, code, tree, boed], Then you would print “code” and “boed” as they can be formed by using the digit sequence and they are also present in the list of valid words.
The first line contains an integer ‘T’ which denotes the number of test cases or queries to be run. Then the test cases are as follows. The first and line of each test case consist of the sequence of numbers. The second line of each test case consists of ‘W’, which denotes the number of given valid words. The third and final line of each test case consists of the list of ‘W’ valid words.
For each test case, print the list of words that can be formed using the given sequence of numbers and are also present in the given list of valid words. Print the output of each test case in a separate line.
You don’t need to print anything; It has already been taken care of. You just need to complete the given function.
1 <= T <= 10 1 <= Sequence <= 10 1 <= W <= 200 where ‘T’ is the number of test cases, “sequence” is the length of the given sequence of numbers, and “W”, is the number of valid words each test case can have. Time limit: 1 sec
Ninja and Numbers
Longest Palindromic Substring