当前位置:网站首页>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
边栏推荐
- sql 常用优化
- Flink并行度和Slot详解
- Training IX basic configuration of network services
- vulnhub之school 1
- 位运算介绍
- 一锅乱炖,npm、yarn cnpm常用命令合集
- 干货分享|DevExpress v22.1原版帮助文档下载集合
- R language dplyr package mutate_ At function and min_ The rank function calculates the sorting sequence number value and ranking value of the specified data column in the dataframe, and assigns the ra
- 如何在软件研发阶段落地安全实践
- LeetCode_7_5
猜你喜欢
随机推荐
JVM GC garbage collection brief
力扣 2319. 判断矩阵是否是一个 X 矩阵
Throughput
R language uses ggplot2 function to visualize the histogram distribution of counting target variables that need to build Poisson regression model, and analyzes the feasibility of building Poisson regr
openEuler 有奖捉虫活动,来参与一下?
tp6 实现佣金排行榜
力扣 459. 重复的子字符串
Tp6 realize Commission ranking
Cloud 组件发展升级
Automatic classification of defective photovoltaic module cells in electroluminescence images-论文阅读笔记
9 原子操作类之18罗汉增强
Semantic slam source code analysis
mock.js从对象数组中任选数据返回一个数组
一文读懂数仓中的pg_stat
开源重器!九章云极DataCanvas公司YLearn因果学习开源项目即将发布!
vulnhub之Funfox2
Nunjuks template engine
Chapter 20 using work queue manager (3)
LeetCode_ 7_ five
ASP.NET体育馆综合会员管理系统源码,免费分享