3407. Substring Matching Pattern Easy
1/**
2 * [3407] Substring Matching Pattern
3 *
4 * You are given a string s and a pattern string p, where p contains exactly one '*' character.
5 * The '*' in p can be replaced with any sequence of zero or more characters.
6 * Return true if p can be made a <span data-keyword="substring-nonempty">substring</span> of s, and false otherwise.
7 *
8 * <strong class="example">Example 1:
9 * <div class="example-block">
10 * Input: <span class="example-io">s = "leetcode", p = "ee*e"</span>
11 * Output: <span class="example-io">true</span>
12 * Explanation:
13 * By replacing the '*' with "tcod", the substring "eetcode" matches the pattern.
14 * </div>
15 * <strong class="example">Example 2:
16 * <div class="example-block">
17 * Input: <span class="example-io">s = "car", p = "c*v"</span>
18 * Output: <span class="example-io">false</span>
19 * Explanation:
20 * There is no substring matching the pattern.
21 * </div>
22 * <strong class="example">Example 3:
23 * <div class="example-block">
24 * Input: <span class="example-io">s = "luck", p = "u*"</span>
25 * Output: <span class="example-io">true</span>
26 * Explanation:
27 * The substrings "u", "uc", and "uck" match the pattern.
28 * </div>
29 *
30 * Constraints:
31 *
32 * 1 <= s.length <= 50
33 * 1 <= p.length <= 50
34 * s contains only lowercase English letters.
35 * p contains only lowercase English letters and exactly one '*'
36 *
37 */
38pub struct Solution {}
39
40// problem: https://leetcode.com/problems/substring-matching-pattern/
41// discuss: https://leetcode.com/problems/substring-matching-pattern/discuss/?currentPage=1&orderBy=most_votes&query=
42
43// submission codes start here
44
45impl Solution {
46 pub fn has_match(s: String, p: String) -> bool {
47 false
48 }
49}
50
51// submission codes end
52
53#[cfg(test)]
54mod tests {
55 use super::*;
56
57 #[test]
58 fn test_3407() {
59 }
60}
61
Back
© 2025 bowen.ge All Rights Reserved.