You are given a array of string followed by two words. You have to find the minimum distance between the two words in the given array of string
(“the”, “quick”, “brown”, “fox”, “quick”)
distance(“fox”,”the”) = 3
distance(“quick”, “fox”) = 1
Input:The first line consists of a integer T denoting the number of test cases .Each test case consists of three lines .First line consists of an integer N denoting the size of array of strings .Second line consists of N spaced strings made of 'a' to 'z' .Third line consists of two spaced strings s1,s2 for which you have two find minimum distance.
Output:The output consists of a single line for each testcase which is the minimum distance between the two given strings.
1<=size of strings of array<=100
It is given that s1 and s2 will always be present in the array
the quick brown fox quick
Expected time complexity
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.