当前位置:网站首页>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边栏推荐
- 接口测试面试题及参考答案,轻松拿捏面试官
- Do you know the performance testing terms to be asked in the software testing interview?
- Global and Chinese markets of electronic grade hexafluorobutadiene (C4F6) 2022-2028: Research Report on technology, participants, trends, market size and share
- Global and Chinese market of pinhole glossmeter 2022-2028: Research Report on technology, participants, trends, market size and share
- [C language] twenty two steps to understand the function stack frame (pressing the stack, passing parameters, returning, bouncing the stack)
- 安全测试入门介绍
- MySQL development - advanced query - take a good look at how it suits you
- Sleep quality today 81 points
- C4D quick start tutorial - Introduction to software interface
- Leetcode simple question: check whether two strings are almost equal
猜你喜欢

Opencv recognition of face in image

The number of reversing twice in leetcode simple question

csapp shell lab
Do you know the performance testing terms to be asked in the software testing interview?

CSAPP shell lab experiment report

Video scrolling subtitle addition, easy to make with this technique

ucore lab6 调度器 实验报告

UCORE lab1 system software startup process experimental report
转行软件测试必需要知道的知识

MySQL development - advanced query - take a good look at how it suits you
随机推荐
Heap, stack, queue
软件测试工作太忙没时间学习怎么办?
ucorelab4
Jupyter installation and use tutorial
Global and Chinese markets for GaN on diamond semiconductor substrates 2022-2028: Research Report on technology, participants, trends, market size and share
If the position is absolute, touchablehighlight cannot be clicked - touchablehighlight not clickable if position absolute
Automated testing problems you must understand, boutique summary
pytest
Leetcode simple question: check whether the numbers in the sentence are increasing
What to do when programmers don't modify bugs? I teach you
Face and eye recognition based on OpenCV's own model
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
[HCIA continuous update] working principle of static route and default route
ucore lab5用户进程管理 实验报告
Portapack application development tutorial (XVII) nRF24L01 launch B
Global and Chinese markets of MPV ACC ECU 2022-2028: Research Report on technology, participants, trends, market size and share
Install and run tensorflow object detection API video object recognition system of Google open source
The minimum sum of the last four digits of the split digit of leetcode simple problem
ucore lab 6
Global and Chinese market for antiviral coatings 2022-2028: Research Report on technology, participants, trends, market size and share