当前位置:网站首页>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边栏推荐
- Practical cases, hand-in-hand teaching you to build e-commerce user portraits | with code
- 转行软件测试必需要知道的知识
- STC-B学习板蜂鸣器播放音乐2.0
- 自动化测试中敏捷测试怎么做?
- What if software testing is too busy to study?
- Pedestrian re identification (Reid) - Overview
- 软件测试工作太忙没时间学习怎么办?
- Build your own application based on Google's open source tensorflow object detection API video object recognition system (II)
- Collection collection and map collection
- Leetcode simple question: check whether two strings are almost equal
猜你喜欢

Introduction to safety testing

UCORE LaB6 scheduler experiment report
How to do agile testing in automated testing?

Build your own application based on Google's open source tensorflow object detection API video object recognition system (II)
转行软件测试必需要知道的知识

Threads and thread pools

Brief description of compiler optimization level

HackTheBox-Emdee five for life

How to write the bug report of software test?

UCORE lab7 synchronous mutual exclusion experiment report
随机推荐
C4D quick start tutorial - Introduction to software interface
Sorting odd and even subscripts respectively for leetcode simple problem
12306: mom, don't worry about me getting the ticket any more (1)
Pedestrian re identification (Reid) - Overview
Threads and thread pools
MySQL数据库(五)视 图 、 存 储 过 程 和 触 发 器
UCORE lab1 system software startup process experimental report
转行软件测试必需要知道的知识
The minimum sum of the last four digits of the split digit of leetcode simple problem
Global and Chinese market of barrier thin film flexible electronics 2022-2028: Research Report on technology, participants, trends, market size and share
CSAPP shell lab experiment report
Stc-b learning board buzzer plays music 2.0
Servlet
[pytorch] simple use of interpolate
Servlet
Réponses aux devoirs du csapp 7 8 9
Global and Chinese market of goat milk powder 2022-2028: Research Report on technology, participants, trends, market size and share
Maximum nesting depth of parentheses in leetcode simple questions
UCORE lab5 user process management experiment report
Description of Vos storage space, bandwidth occupation and PPS requirements