最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

LeetCode 1456. Maximum Number of Vowels in a Substring of Given

2023-02-12 08:12 作者:您是打尖兒還是住店呢  | 我要投稿

Given a string?s?and an integer?k, return?the maximum number of vowel letters in any substring of?s?with length?k.

Vowel letters?in English are?'a',?'e',?'i',?'o', and?'u'.

?

Example 1:

Input: s = "abciiidef", k = 3Output: 3Explanation: The substring "iii" contains 3 vowel letters.

Example 2:

Input: s = "aeiou", k = 2Output: 2Explanation: Any substring of length 2 contains 2 vowels.

Example 3:

Input: s = "leetcode", k = 3Output: 2Explanation: "lee", "eet" and "ode" contain 2 vowels.

?

Constraints:

  • 1 <= s.length <= 105

  • s?consists of lowercase English letters.

  • 1 <= k <= s.length

1:寫一個方法,判斷是否是元音字母;

2:設(shè)置一個前綴和的數(shù)組;

3:依次判斷連續(xù)K個數(shù)字之和,保存最大值;

4:返回最大值;



Runtime:?7 ms, faster than?99.58%?of?Java?online submissions for?Maximum Number of Vowels in a Substring of Given Length.

Memory Usage:?43.2 MB, less than?31.48%?of?Java?online submissions for?Maximum Number of Vowels in a Substring of Given Length.


LeetCode 1456. Maximum Number of Vowels in a Substring of Given 的評論 (共 條)

分享到微博請遵守國家法律
邳州市| 鹤山市| 张家界市| 邓州市| 台东市| 紫云| 广德县| 纳雍县| 宜城市| 元谋县| 丹凤县| 永宁县| 额济纳旗| 霍州市| 肇州县| 呼玛县| 铜陵市| 浦江县| 怀远县| 如东县| 铁岭市| 灵石县| 延边| 乌审旗| 宣武区| 长武县| 万山特区| 罗定市| 汝州市| 建昌县| 永兴县| 尤溪县| 巴林右旗| 浑源县| 罗甸县| 都昌县| 卢龙县| 丹凤县| 汝阳县| 刚察县| 宜丰县|