当前位置:网站首页>Force buckle 2315 Statistical asterisk
Force buckle 2315 Statistical asterisk
2022-07-07 20:06:00 【Tomorrowave】
List of articles
2315. Statistical asterisk
Give you a string s , Every time Two Continuous vertical line ‘|’ by a pair . In other words , The first and the second ‘|’ It's a couple , The third and the fourth ‘|’ It's a couple , And so on .
Please return be not in Between vertical line pairs ,s in ‘*’ Number of .
Be careful , Each vertical line ‘|’ Metropolis just Belong to a pair .
Example 1:
Input :s = “l|eet|co|*de|"
Output :2
explain : Characters not between vertical line pairs are bold and italicized , Get a string :"l|eet|co|*de|” .
The first and second vertical lines ‘|’ Characters between are not included in the answer .
meanwhile , The third and fourth vertical lines ‘|’ Characters between are not included in the answer .
There is a total of... Between vertical line pairs 2 asterisk , So we go back to 2 .
Ideas :
matching
Code section
class Solution(object):
def countAsterisks(self, s):
""" :type s: str :rtype: int """
cnt=0
c=0
for i in s:
if i=='|':
cnt+=1
elif cnt%2==0 and i=='*':
c+=1
return c
边栏推荐
- Some important knowledge of MySQL
- Dynamic addition of El upload upload component; El upload dynamically uploads files; El upload distinguishes which component uploads the file.
- gorilla官方:golang开websocket client的示例代码
- Automatic classification of defective photovoltaic module cells in electroluminescence images-论文阅读笔记
- Nunjuks template engine
- 力扣 88.合并两个有序数组
- 编译器优化那些事儿(4):归纳变量
- 831. KMP字符串
- 数据孤岛是企业数字化转型遇到的第一道险关
- Classification automatique des cellules de modules photovoltaïques par défaut dans les images de lecture électronique - notes de lecture de thèse
猜你喜欢
PMP對工作有益嗎?怎麼選擇靠譜平臺讓備考更省心省力!!!
使用高斯Redis实现二级索引
Redis——基本使用(key、String、List、Set 、Zset 、Hash、Geo、Bitmap、Hyperloglog、事务 )
九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
Implement secondary index with Gaussian redis
Detailed explanation of Flink parallelism and slot
华南X99平台打鸡血教程
The project manager's "eight interview questions" is equal to a meeting
Make this crmeb single merchant wechat mall system popular, so easy to use!
Welcome to the markdown editor
随机推荐
毕业季|遗憾而又幸运的毕业季
Data island is the first danger encountered by enterprises in their digital transformation
A pot of stew, a collection of common commands of NPM and yarn cnpm
小试牛刀之NunJucks模板引擎
pom.xml 配置文件标签作用简述
SQL common optimization
【STL】vector
华南X99平台打鸡血教程
Equals method
关于cv2.dnn.readNetFromONNX(path)就报ERROR during processing node with 3 inputs and 1 outputs的解决过程【独家发布】
MSE API学习
J ü rgen schmidhub reviews the 25th anniversary of LSTM papers: long short term memory All computable metaverses. Hierarchical reinforcement learning (RL). Meta-RL. Abstractions in generative adversar
Time tools
Openeuler prize catching activities, to participate in?
开源OA开发平台:合同管理使用手册
让这个 CRMEB 单商户微信商城系统火起来,太好用了!
R语言ggplot2可视化:使用ggpubr包的ggqqplot函数可视化QQ图(Quantile-Quantile plot)
力扣 459. 重复的子字符串
ASP. Net kindergarten chain management system source code
Ucloud is a basic cloud computing service provider