当前位置:网站首页>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数据库(三)高级数据查询语句
- What if software testing is too busy to study?
- Should wildcard import be avoided- Should wildcard import be avoided?
- Global and Chinese market of barrier thin film flexible electronics 2022-2028: Research Report on technology, participants, trends, market size and share
- Word macro operation: convert the automatic number in the document into editable text type
- MySQL数据库(二)DML数据操作语句和基本的DQL语句
- Mysql database (III) advanced data query statement
- Programmers, how to avoid invalid meetings?
- What are the commonly used SQL statements in software testing?
- UCORE lab5 user process management experiment report
猜你喜欢
Dlib detects blink times based on video stream
UCORE LaB6 scheduler experiment report
ucore lab7 同步互斥 实验报告
[C language] twenty two steps to understand the function stack frame (pressing the stack, passing parameters, returning, bouncing the stack)
软件测试行业的未来趋势及规划
想跳槽?面试软件测试需要掌握的7个技能你知道吗
HackTheBox-Emdee five for life
UCORE lab1 system software startup process experimental report
The maximum number of words in the sentence of leetcode simple question
The most detailed postman interface test tutorial in the whole network. An article meets your needs
随机推荐
UCORE lab5 user process management experiment report
UCORE lab1 system software startup process experimental report
How to write the bug report of software test?
Crawler series of learning while tapping (3): URL de duplication strategy and Implementation
CSAPP家庭作业答案7 8 9章
Lab 8 file system
Collection集合与Map集合
如何成为一个好的软件测试员?绝大多数人都不知道的秘密
Nest and merge new videos, and preset new video titles
JDBC introduction
自动化测试中敏捷测试怎么做?
Global and Chinese market of RF shielding room 2022-2028: Research Report on technology, participants, trends, market size and share
The minimum sum of the last four digits of the split digit of leetcode simple problem
ucore lab6 调度器 实验报告
JDBC介绍
Knowledge that you need to know when changing to software testing
UCORE LaB6 scheduler experiment report
Opencv recognition of face in image
Introduction to safety testing
[200 opencv routines] 98 Statistical sorting filter