1456. Maximum Number of Vowels in a Substring of Given Length Medium

@problem@discussion
#String#Sliding Window



1/**
2 * [1456] Maximum Number of Vowels in a Substring of Given Length
3 *
4 * Given a string s and an integer k, return the maximum number of vowel letters in any substring of s with length k.
5 * Vowel letters in English are 'a', 'e', 'i', 'o', and 'u'.
6 *  
7 * Example 1:
8 * 
9 * Input: s = "abciiidef", k = 3
10 * Output: 3
11 * Explanation: The substring "iii" contains 3 vowel letters.
12 * 
13 * Example 2:
14 * 
15 * Input: s = "aeiou", k = 2
16 * Output: 2
17 * Explanation: Any substring of length 2 contains 2 vowels.
18 * 
19 * Example 3:
20 * 
21 * Input: s = "leetcode", k = 3
22 * Output: 2
23 * Explanation: "lee", "eet" and "ode" contain 2 vowels.
24 * 
25 *  
26 * Constraints:
27 * 
28 * 	1 <= s.length <= 10^5
29 * 	s consists of lowercase English letters.
30 * 	1 <= k <= s.length
31 * 
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/maximum-number-of-vowels-in-a-substring-of-given-length/
36// discuss: https://leetcode.com/problems/maximum-number-of-vowels-in-a-substring-of-given-length/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41    pub fn max_vowels(s: String, k: i32) -> i32 {
42        0
43    }
44}
45
46// submission codes end
47
48#[cfg(test)]
49mod tests {
50    use super::*;
51
52    #[test]
53    fn test_1456() {
54    }
55}
56


Back
© 2025 bowen.ge All Rights Reserved.