567. Permutation in String Medium

@problem@discussion
#Hash Table#Two Pointers#String#Sliding Window



1/**
2 * [567] Permutation in String
3 *
4 * Given two strings s1 and s2, return true if s2 contains a permutation of s1, or false otherwise.
5 * In other words, return true if one of s1's permutations is the substring of s2.
6 *  
7 * Example 1:
8 * 
9 * Input: s1 = "ab", s2 = "eidbaooo"
10 * Output: true
11 * Explanation: s2 contains one permutation of s1 ("ba").
12 * 
13 * Example 2:
14 * 
15 * Input: s1 = "ab", s2 = "eidboaoo"
16 * Output: false
17 * 
18 *  
19 * Constraints:
20 * 
21 * 	1 <= s1.length, s2.length <= 10^4
22 * 	s1 and s2 consist of lowercase English letters.
23 * 
24 */
25pub struct Solution {}
26
27// problem: https://leetcode.com/problems/permutation-in-string/
28// discuss: https://leetcode.com/problems/permutation-in-string/discuss/?currentPage=1&orderBy=most_votes&query=
29
30// submission codes start here
31
32impl Solution {
33    pub fn check_inclusion(s1: String, s2: String) -> bool {
34        false
35    }
36}
37
38// submission codes end
39
40#[cfg(test)]
41mod tests {
42    use super::*;
43
44    #[test]
45    fn test_567() {
46    }
47}
48


Back
© 2025 bowen.ge All Rights Reserved.