{"id":"27567e58-debc-408b-8b8a-c5f73cbb3fd7","name":"Pattern Matching","description":"1. You are given a string and a pattern. \r\n2. You've to check if the string is of the same structure as pattern without using any regular \r\n expressions.\r\n\r\nNote -> Check out the question video and write the recursive code as it is intended without \r\n changing signature. The judge can't force you but intends you to teach a concept.","inputFormat":"A String str\r\nA pattern ptr","outputFormat":"Check the sample ouput and question video.","constraints":"1 &lt;= length of str,ptr &lt;= 20","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static void solution(String str, String pattern, HashMap<Character,String> map, String op){\r\n\t\t//write your code here\r\n\t\t\r\n\t}\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tString str = scn.next();\r\n\t\tString pattern = scn.next();\r\n\t\tHashMap<Character,String> map = new HashMap<>();\r\n\t\tsolution(str,pattern,map,pattern);\r\n\t}\r\n}"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"graphtreesgraph\r\npep","sampleOutput":"p -> graph, e -> trees, . \r\n","questionVideo":"https://www.youtube.com/embed/aVMyXDuSLNM?end=123","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"082986ae-d618-4a59-9ab3-6d79056679a4","name":"Recursion and Backtracking For Intermediate","slug":"recursion-and-backtracking-for-intermediate-330","type":0},{"id":"7940e7f8-6d5c-4fa9-8866-213093c3e56c","name":"Pattern Matching","slug":"pattern-matching","type":1}],"next":{"id":"7a4b9f01-5eef-401b-ac55-59891259a185","name":"Pattern Matching MCQ","type":0,"slug":"pattern-matching-mcq"},"prev":{"id":"2fac67f3-b404-475b-87a7-b93bc06832e6","name":"K Subsets With Equal Sum MCQ","type":0,"slug":"k-subsets-with-equal-sum-mcq"}}}

Pattern Matching

1. You are given a string and a pattern. 2. You've to check if the string is of the same structure as pattern without using any regular expressions. Note -> Check out the question video and write the recursive code as it is intended without changing signature. The judge can't force you but intends you to teach a concept.

{"id":"27567e58-debc-408b-8b8a-c5f73cbb3fd7","name":"Pattern Matching","description":"1. You are given a string and a pattern. \r\n2. You've to check if the string is of the same structure as pattern without using any regular \r\n expressions.\r\n\r\nNote -> Check out the question video and write the recursive code as it is intended without \r\n changing signature. The judge can't force you but intends you to teach a concept.","inputFormat":"A String str\r\nA pattern ptr","outputFormat":"Check the sample ouput and question video.","constraints":"1 &lt;= length of str,ptr &lt;= 20","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static void solution(String str, String pattern, HashMap<Character,String> map, String op){\r\n\t\t//write your code here\r\n\t\t\r\n\t}\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tString str = scn.next();\r\n\t\tString pattern = scn.next();\r\n\t\tHashMap<Character,String> map = new HashMap<>();\r\n\t\tsolution(str,pattern,map,pattern);\r\n\t}\r\n}"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"graphtreesgraph\r\npep","sampleOutput":"p -> graph, e -> trees, . \r\n","questionVideo":"https://www.youtube.com/embed/aVMyXDuSLNM?end=123","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"082986ae-d618-4a59-9ab3-6d79056679a4","name":"Recursion and Backtracking For Intermediate","slug":"recursion-and-backtracking-for-intermediate-330","type":0},{"id":"7940e7f8-6d5c-4fa9-8866-213093c3e56c","name":"Pattern Matching","slug":"pattern-matching","type":1}],"next":{"id":"7a4b9f01-5eef-401b-ac55-59891259a185","name":"Pattern Matching MCQ","type":0,"slug":"pattern-matching-mcq"},"prev":{"id":"2fac67f3-b404-475b-87a7-b93bc06832e6","name":"K Subsets With Equal Sum MCQ","type":0,"slug":"k-subsets-with-equal-sum-mcq"}}}
plane

Editor


Loading...

Pattern Matching

medium

1. You are given a string and a pattern. 2. You've to check if the string is of the same structure as pattern without using any regular expressions. Note -> Check out the question video and write the recursive code as it is intended without changing signature. The judge can't force you but intends you to teach a concept.

Constraints

1 <= length of str,ptr <= 20

Format

Input

A String str A pattern ptr

Output

Check the sample ouput and question video.

Example

Sample Input

graphtreesgraph pep

Sample Output

p -> graph, e -> trees, .

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode