当前位置:网站首页>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边栏推荐
- 基于485总线的评分系统双机实验报告
- pytest
- Automated testing problems you must understand, boutique summary
- Should wildcard import be avoided- Should wildcard import be avoided?
- [pytorch] simple use of interpolate
- Global and Chinese market of pinhole glossmeter 2022-2028: Research Report on technology, participants, trends, market size and share
- UCORE LaB6 scheduler experiment report
- CSAPP家庭作業答案7 8 9章
- Investment should be calm
- Do you know the performance testing terms to be asked in the software testing interview?
猜你喜欢
随机推荐
Lab 8 file system
Leetcode simple question: check whether two strings are almost equal
Expanded polystyrene (EPS) global and Chinese markets 2022-2028: technology, participants, trends, market size and share Research Report
ArrayList集合
Thinking about three cups of tea
[pytorch] simple use of interpolate
Mysql database (V) views, stored procedures and triggers
Global and Chinese market of maleic acid modified rosin esters 2022-2028: Research Report on technology, participants, trends, market size and share
JDBC介绍
转行软件测试必需要知道的知识
ucore lab7
ucore Lab 1 系统软件启动过程
What if software testing is too busy to study?
软件测试行业的未来趋势及规划
Global and Chinese markets for GaN on diamond semiconductor substrates 2022-2028: Research Report on technology, participants, trends, market size and share
Nest and merge new videos, and preset new video titles
ucore lab5
软件测试有哪些常用的SQL语句?
Heap, stack, queue
MySQL数据库(五)视 图 、 存 储 过 程 和 触 发 器









