Difficulty Level: Easy

Submissions: 1905 Accuracy:


Match specific pattern (Function Problem)

Given a dictionary of words and a pattern.  Every character in the pattern is uniquely mapped to a character in the dictionary.

The task is to complete a function  findMatchedWords that returns a vector of  strings matching with given pattern. The function takes two argument the first argument is an array of strings which denote the dictionary and the second argument is the pattern to match.

The first line of input contains an integer T denoting the no of test cases . Then T test cases follow . The first line of each test case contains an integer N denoting the no of strings in the dictionary and then in the next line are N space separated strings denoting the strings of the dictionary. Then in the next line is a string pattern.

The output for each test case will be the space separated strings that matches the given pattern in lexicographical order.

Example(To be used only for expected output):

abb abc  xyz xyy

abb xyy

In the above test case xyy and abb have same character at index 1 and 2 like the pattern.

Note:The Input/Ouput format and Example given are used for system's internal purpose, and should be used by a user for Expected Output only. As it is a function problem, hence a user should not read any input from stdin/console. The task is to complete the function specified, and not to write the full code.

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Harshit Sidhwa
Author: Shubham Joshi 1

It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use, generate link and share the link here.