Browser tab content: Problem List 0 Debugging... Run Submit 00:00:00 Description…
- User
Browser tab content: Problem List 0 Debugging... Run Submit 00:00:00 Description Editorial Editorial Solutions Solutions Submissions Submissions Code Note Note Testcase Testcase Test Result 44. Wildcard Matching Solved Hard Topics Companies
Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*' where:
'?' Matches any single character. '*' Matches any sequence of characters (including the empty sequence).
The matching should cover the entire input string (not partial).
Example 1:
Input: s = "aa", p = "a" Output: false Explanation: "a" does not match the entire string "aa".
Example 2:
Input: s = "aa", p = "" Output: true Explanation: '' matches any sequence.
Example 3:
Input: s = "cb", p = "?a" Output: false Explanation: '?' matches 'c', but the second letter is 'a', which does not match 'b'.
Constraints:
0 <= s.length, p.length <= 2000 s contains only lowercase English letters. p contains only lowercase English letters, '?' or '*'. Seen this question in a real interview before? 1/5 Yes No Accepted 642.8K Submissions 2.2M Acceptance Rate 28.9% Topics String Dynamic Programming Greedy Recursion Companies 0 - 3 months Meta 4 Bloomberg 4 Microsoft 3 Amazon 3 0 - 6 months Google 5 Zoho 2 X 2 Snap 2 Two Sigma 2 Instacart 2 6 months ago Apple 10 Adobe 8 Uber 4 Confluent 4 Yahoo 3 Walmart Labs 2 Salesforce 2 PhonePe 2 Coursera 2 Similar Questions Regular Expression Matching Hard Discussion (91) Choose a type Preview Comment 💡 Discussion Rules
-
Please don't post any solutions in this discussion.
-
The problem discussion is for asking questions about the problem or for sharing tips - anything except for solutions.
-
If you'd like to share your solution for feedback and ideas, please head to the solutions tab and post it there.
Sort by:Best No comments yet. 1 2 3 4 5 6 10 Copyright ©️ 2024 LeetCode All rights reserved 8.4K 91 51 Online Java Auto 1 2 3 4 5 class Solution { public boolean isMatch(String s, String p) { } } Saved Ln 5, Col 2 Accepted Runtime: 0 ms Case 1 Case 2 Case 3 Input s = "aa" p = "a" Output false Expected false Contribute a testcase Input 1 2 3 4 5 6 "aa" "a" "aa" "*" "cb" "?a" Output 1 2 3 false true false Expected 1 2 3 false true false
Tag
Remove distracting text, extract the programming question, provide simple, common, and optimized Java solution for it.
-
- Assistant