当前位置:网站首页>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边栏推荐
- Capitalize the title of leetcode simple question
- MySQL数据库(三)高级数据查询语句
- Global and Chinese market of goat milk powder 2022-2028: Research Report on technology, participants, trends, market size and share
- Winter vacation daily question - maximum number of balloons
- [200 opencv routines] 98 Statistical sorting filter
- How to change XML attribute - how to change XML attribute
- Leetcode simple question: check whether two strings are almost equal
- Preface to the foundations of Hilbert geometry
- The number of reversing twice in leetcode simple question
- Description of Vos storage space, bandwidth occupation and PPS requirements
猜你喜欢

Winter vacation daily question - maximum number of balloons

Stc-b learning board buzzer plays music 2.0

線程及線程池

How to build a nail robot that can automatically reply

Opencv recognition of face in image

想跳槽?面试软件测试需要掌握的7个技能你知道吗

Word macro operation: convert the automatic number in the document into editable text type

How to write the bug report of software test?

Do you know the advantages and disadvantages of several open source automated testing frameworks?

Example 071 simulates a vending machine, designs a program of the vending machine, runs the program, prompts the user, enters the options to be selected, and prompts the selected content after the use
随机推荐
What is "test paper test" in software testing requirements analysis
The latest query tracks the express logistics and analyzes the method of delivery timeliness
基于485总线的评分系统
What if software testing is too busy to study?
Practical cases, hand-in-hand teaching you to build e-commerce user portraits | with code
Contest3145 - the 37th game of 2021 freshman individual training match_ A: Prizes
Global and Chinese markets for GaN on diamond semiconductor substrates 2022-2028: Research Report on technology, participants, trends, market size and share
软件测试Bug报告怎么写?
Crawler series of learning while tapping (3): URL de duplication strategy and Implementation
Video scrolling subtitle addition, easy to make with this technique
Should wildcard import be avoided- Should wildcard import be avoided?
MySQL数据库(三)高级数据查询语句
Capitalize the title of leetcode simple question
Portapack application development tutorial (XVII) nRF24L01 launch B
Global and Chinese markets of cobalt 2022-2028: Research Report on technology, participants, trends, market size and share
51 lines of code, self-made TX to MySQL software!
ucore lab5用户进程管理 实验报告
ucore lab8 文件系统 实验报告
How to rename multiple folders and add unified new content to folder names
Threads et pools de threads