当前位置:网站首页>力扣 2315.统计星号
力扣 2315.统计星号
2022-07-07 17:53:00 【Tomorrowave】
2315.统计星号
给你一个字符串 s ,每 两个 连续竖线 ‘|’ 为 一对 。换言之,第一个和第二个 ‘|’ 为一对,第三个和第四个 ‘|’ 为一对,以此类推。
请你返回 不在 竖线对之间,s 中 ‘*’ 的数目。
注意,每个竖线 ‘|’ 都会 恰好 属于一个对。
示例 1:
输入:s = “l|eet|co|*de|"
输出:2
解释:不在竖线对之间的字符加粗加斜体后,得到字符串:"l|eet|co|*de|” 。
第一和第二条竖线 ‘|’ 之间的字符不计入答案。
同时,第三条和第四条竖线 ‘|’ 之间的字符也不计入答案。
不在竖线对之间总共有 2 个星号,所以我们返回 2 。
思路:
匹配
代码部分
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
边栏推荐
- Flink并行度和Slot详解
- LeetCode_ 7_ five
- IP tools
- 编译器优化那些事儿(4):归纳变量
- 让这个 CRMEB 单商户微信商城系统火起来,太好用了!
- 【RT-Thread env 工具安装】
- Dynamic addition of El upload upload component; El upload dynamically uploads files; El upload distinguishes which component uploads the file.
- R language dplyr package select function, group_ The by function, filter function and do function obtain the third largest value of a specific numerical data column in a specified level in a specified
- Interpretation of transpose convolution theory (input-output size analysis)
- 怎么在手机上买股票开户 股票开户安全吗
猜你喜欢
Redis——基本使用(key、String、List、Set 、Zset 、Hash、Geo、Bitmap、Hyperloglog、事务 )
Automatic classification of defective photovoltaic module cells in electroluminescence images-论文阅读笔记
项目经理『面试八问』,看了等于会了
爬虫实战(七):爬王者英雄图片
关于cv2.dnn.readNetFromONNX(path)就报ERROR during processing node with 3 inputs and 1 outputs的解决过程【独家发布】
使用高斯Redis实现二级索引
开源OA开发平台:合同管理使用手册
PMP practice once a day | don't get lost in the exam -7.7
Matplotlib drawing 3D graphics
Kirin Xin'an cloud platform is newly upgraded!
随机推荐
A pot of stew, a collection of common commands of NPM and yarn cnpm
Netease Yunxin participated in the preparation of the standard "real time audio and video service (RTC) basic capability requirements and evaluation methods" issued by the Chinese Academy of Communica
Openeuler prize catching activities, to participate in?
The research group of the Hunan Organizing Committee of the 24th China Association for science and technology visited Kirin Xin'an
Notes...
Kirin Xin'an cloud platform is newly upgraded!
关于cv2.dnn.readNetFromONNX(path)就报ERROR during processing node with 3 inputs and 1 outputs的解决过程【独家发布】
项目经理『面试八问』,看了等于会了
openEuler 资源利用率提升之道 01:概论
The strength index of specialized and new software development enterprises was released, and Kirin Xin'an was honored on the list
九章云极DataCanvas公司获评36氪「最受投资人关注的硬核科技企业」
CSDN语法说明
R语言dplyr包mutate_at函数和min_rank函数计算dataframe中指定数据列的排序序号值、名次值、将最大值的rank值赋值为1
el-upload上传组件的动态添加;el-upload动态上传文件;el-upload区分文件是哪个组件上传的。
sql 常用优化
Implement secondary index with Gaussian redis
831. KMP string
Flink并行度和Slot详解
Specify the version of OpenCV non-standard installation
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