290. Word Pattern Easy
1/**
2 * [290] Word Pattern
3 *
4 * Given a pattern and a string s, find if s follows the same pattern.
5 * Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in s.
6 *
7 * Example 1:
8 *
9 * Input: pattern = "abba", s = "dog cat cat dog"
10 * Output: true
11 *
12 * Example 2:
13 *
14 * Input: pattern = "abba", s = "dog cat cat fish"
15 * Output: false
16 *
17 * Example 3:
18 *
19 * Input: pattern = "aaaa", s = "dog cat cat dog"
20 * Output: false
21 *
22 *
23 * Constraints:
24 *
25 * 1 <= pattern.length <= 300
26 * pattern contains only lower-case English letters.
27 * 1 <= s.length <= 3000
28 * s contains only lowercase English letters and spaces ' '.
29 * s does not contain any leading or trailing spaces.
30 * All the words in s are separated by a single space.
31 *
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/word-pattern/
36// discuss: https://leetcode.com/problems/word-pattern/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41 pub fn word_pattern(pattern: String, s: String) -> bool {
42 false
43 }
44}
45
46// submission codes end
47
48#[cfg(test)]
49mod tests {
50 use super::*;
51
52 #[test]
53 fn test_290() {
54 }
55}
56
Back
© 2025 bowen.ge All Rights Reserved.