当前位置:网站首页>LeetCode#2062. Count vowel substrings in strings
LeetCode#2062. Count vowel substrings in strings
2022-07-06 15:21:00 【Rufeng ZHHH】
subject :
Substring Is a continuous... In a string ( Non empty ) The character sequence of .
Vowel substring yes only By vowels ('a'、'e'、'i'、'o' and 'u') A substring composed of , And it must contain All five vowel .
Give you a string word , Count and return word in Number of vowel substrings .
Example 1:
Input :word = "aeiouu"
Output :2
explain : The following is a list word Vowel substring in ( Bold part in italics ):
- "aeiouu"
- "aeiouu"
Example 2:
Input :word = "unicornarihan"
Output :0
explain :word Does not include 5 Kinds of vowels , So there will be no vowel substring .
Example 3:
Input :word = "cuaieuouac"
Output :7
explain : The following is a list word Vowel substring in ( Bold part in italics ):
- "cuaieuouac"
- "cuaieuouac"
- "cuaieuouac"
- "cuaieuouac"
- "cuaieuouac"
- "cuaieuouac"
- "cuaieuouac"
Example 4:
Input :word = "bbaeixoubb"
Output :0
explain : All substrings containing all five vowels contain consonants , So there is no vowel substring .
Tips :
1 <= word.length <= 100
word It's only made up of lowercase letters
source : Power button (LeetCode)
link : Power button
The judgment substring of this question only needs to meet the conditions required by the question :
Substring Is a continuous... In a string ( Non empty ) The character sequence of .
Vowel substring yes only By vowels ('a'、'e'、'i'、'o' and 'u') A substring composed of , And it must contain All five vowel .
I used double pointer to solve . The key is to deal with the fast pointer in word Action at the end of .
class Solution:
def countVowelSubstrings(self, word: str) -> int:
count=0;store="aeiou"
pre=0;cur=5
while len(word[pre:cur])==5:
now=cur
while cur<=len(word):
for i in word[pre:cur]:
if i in store:
a=True
continue
else:
a=False
break
if a:
for i in store:
if word[pre:cur].count(i)>0:
a=True
continue
else:
a=False
break
if a:
count+=1
cur+=1
pre+=1
cur=now+1
return count
边栏推荐
- MySQL数据库(三)高级数据查询语句
- Knowledge that you need to know when changing to software testing
- 51 lines of code, self-made TX to MySQL software!
- CSAPP家庭作业答案7 8 9章
- Leetcode notes - dynamic planning -day6
- Thinking about three cups of tea
- Emqtt distribution cluster and node bridge construction
- Report on the double computer experiment of scoring system based on 485 bus
- Stc-b learning board buzzer plays music
- Global and Chinese market of portable and handheld TVs 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢
CSAPP homework answers chapter 789
Stc-b learning board buzzer plays music 2.0
想跳槽?面试软件测试需要掌握的7个技能你知道吗
Sorting odd and even subscripts respectively for leetcode simple problem
ucore lab6 调度器 实验报告
STC-B学习板蜂鸣器播放音乐2.0
12306: mom, don't worry about me getting the ticket any more (1)
Want to change jobs? Do you know the seven skills you need to master in the interview software test
How to write the bug report of software test?
软件测试Bug报告怎么写?
随机推荐
Video scrolling subtitle addition, easy to make with this technique
Threads and thread pools
Sorting odd and even subscripts respectively for leetcode simple problem
MySQL数据库(三)高级数据查询语句
Global and Chinese markets of PIM analyzers 2022-2028: Research Report on technology, participants, trends, market size and share
CSAPP homework answers chapter 789
STC-B学习板蜂鸣器播放音乐2.0
Lab 8 file system
Report on the double computer experiment of scoring system based on 485 bus
If the position is absolute, touchablehighlight cannot be clicked - touchablehighlight not clickable if position absolute
Global and Chinese market of portable and handheld TVs 2022-2028: Research Report on technology, participants, trends, market size and share
Dlib detects blink times based on video stream
Servlet
Leetcode notes - dynamic planning -day7
MySQL数据库(一)
Brief introduction to libevent
What to do when programmers don't modify bugs? I teach you
How to do agile testing in automated testing?
Global and Chinese markets for complex programmable logic devices 2022-2028: Research Report on technology, participants, trends, market size and share
How to change XML attribute - how to change XML attribute