The first line contains an integer 'T' which denotes the number of test cases or queries to be run.
The first line of each test case contains a single integer ‘N’ denoting the size of the ‘blockages’ array.
The next line contains ‘N’ space-separated strings denoting the values of the ‘blockages’ array.
The third line contains a single string denoting the ‘result’ value.
For each test case, print a single line containing numbers of turns or -1 as per the condition.
The output of each test case will be printed in a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 5
1 <= N <= 500
blockages[i].length == 4
result.length == 4
result will not be in the list blockages
result and blockages[i] consists of only digits from ‘0’ to ‘9’.
Time Limit: 1sec
The idea here is to use the unordered set of the same size as the ‘blockages’ and use a queue to insert the strings which are not visited as well as are not present in the ‘blockages’. Also,instead of dealing with the string , change them into integers and then move forward towards the result.
Stock Span
Hills and Soldier
Hills and Soldier
Next Greater Element II
Merge Two Sorted Arrays Without Extra Space
Co-Prime