{"id":"5f2e226e-b1aa-44bf-a114-369c3969fcaa","name":"Wildcard Pattern Matching","description":"1. You are given two strings S1 and S2. S1 represents a text and S2 represents a wildcard pattern.\r\n2. You have to print 'true' if the wildcard pattern is matched with the given text, otherwise print 'false'.\r\n\r\nThe wildcard pattern can include the characters '?' and '*'\r\n'?' - matches any single character\r\n'*' - matches any sequence of characters (including the empty sequence)","inputFormat":"2 strings S1 and S2","outputFormat":"Check the sample output and question video.","constraints":"1 < length of strings S1 and S2 <= 200","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static boolean solution(String str, String pattern) {\r\n\t\t//write your code here\r\n\t\t\r\n\t\treturn false;\r\n\t}\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tString s1 = scn.next();\r\n\t\tString s2 = scn.next();\r\n\t\tSystem.out.println(solution(s1,s2));\r\n\t}\r\n\r\n}"},"node":{"code":""},"ruby":{"code":""},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"baaabab\r\nba*a?","sampleOutput":"true\r\n","questionVideo":"https://www.youtube.com/embed/NbgUZAoIz3g?end=65","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":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"08cff114-e27a-4608-8cd6-f54376ebab84","name":"Wildcard Pattern Matching","slug":"wildcard-pattern-matching","type":1}],"next":{"id":"543c8cc6-0fba-43e1-9fb3-920a0b688dec","name":"Wildcard pattern matching MCQ","type":0,"slug":"wildcard-pattern-matching-mcq"},"prev":{"id":"66eb703d-1809-49db-9daa-0ff2f9c68319","name":"Print All Paths With Target Sum Subset","type":3,"slug":"print-all-paths-with-target-sum-subset"}}}

Wildcard Pattern Matching

1. You are given two strings S1 and S2. S1 represents a text and S2 represents a wildcard pattern. 2. You have to print 'true' if the wildcard pattern is matched with the given text, otherwise print 'false'. The wildcard pattern can include the characters '?' and '*' '?' - matches any single character '*' - matches any sequence of characters (including the empty sequence)

{"id":"5f2e226e-b1aa-44bf-a114-369c3969fcaa","name":"Wildcard Pattern Matching","description":"1. You are given two strings S1 and S2. S1 represents a text and S2 represents a wildcard pattern.\r\n2. You have to print 'true' if the wildcard pattern is matched with the given text, otherwise print 'false'.\r\n\r\nThe wildcard pattern can include the characters '?' and '*'\r\n'?' - matches any single character\r\n'*' - matches any sequence of characters (including the empty sequence)","inputFormat":"2 strings S1 and S2","outputFormat":"Check the sample output and question video.","constraints":"1 < length of strings S1 and S2 <= 200","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static boolean solution(String str, String pattern) {\r\n\t\t//write your code here\r\n\t\t\r\n\t\treturn false;\r\n\t}\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tString s1 = scn.next();\r\n\t\tString s2 = scn.next();\r\n\t\tSystem.out.println(solution(s1,s2));\r\n\t}\r\n\r\n}"},"node":{"code":""},"ruby":{"code":""},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"baaabab\r\nba*a?","sampleOutput":"true\r\n","questionVideo":"https://www.youtube.com/embed/NbgUZAoIz3g?end=65","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":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"08cff114-e27a-4608-8cd6-f54376ebab84","name":"Wildcard Pattern Matching","slug":"wildcard-pattern-matching","type":1}],"next":{"id":"543c8cc6-0fba-43e1-9fb3-920a0b688dec","name":"Wildcard pattern matching MCQ","type":0,"slug":"wildcard-pattern-matching-mcq"},"prev":{"id":"66eb703d-1809-49db-9daa-0ff2f9c68319","name":"Print All Paths With Target Sum Subset","type":3,"slug":"print-all-paths-with-target-sum-subset"}}}
plane

Editor


Loading...

Wildcard Pattern Matching

medium

1. You are given two strings S1 and S2. S1 represents a text and S2 represents a wildcard pattern. 2. You have to print 'true' if the wildcard pattern is matched with the given text, otherwise print 'false'. The wildcard pattern can include the characters '?' and '*' '?' - matches any single character '*' - matches any sequence of characters (including the empty sequence)

Constraints

1 < length of strings S1 and S2 <= 200

Format

Input

2 strings S1 and S2

Output

Check the sample output and question video.

Example

Sample Input

baaabab ba*a?

Sample Output

true

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode