当前位置:网站首页>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
边栏推荐
- BI的边界:BI不适合做什么?主数据、MarTech?该如何扩展?
- 模拟实现string类
- R语言ggplot2可视化:使用ggpubr包的ggqqplot函数可视化QQ图(Quantile-Quantile plot)
- 银行理财产品怎么买?需要办银行卡吗?
- 华南X99平台打鸡血教程
- pom.xml 配置文件标签作用简述
- The state cyberspace Office released the measures for data exit security assessment: 100000 information provided overseas needs to be declared
- How to cooperate among multiple threads
- 干货分享|DevExpress v22.1原版帮助文档下载集合
- 国家网信办公布《数据出境安全评估办法》:累计向境外提供10万人信息需申报
猜你喜欢
Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記
vulnhub之school 1
力扣 2319. 判断矩阵是否是一个 X 矩阵
论文解读(ValidUtil)《Rethinking the Setting of Semi-supervised Learning on Graphs》
Flink并行度和Slot详解
PMP對工作有益嗎?怎麼選擇靠譜平臺讓備考更省心省力!!!
模拟实现string类
九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
【STL】vector
vulnhub之tre1
随机推荐
Welcome to the markdown editor
Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記
Automatic classification of defective photovoltaic module cells in electroluminescence images-论文阅读笔记
Data island is the first danger encountered by enterprises in their digital transformation
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
Compiler optimization (4): inductive variables
pom. XML configuration file label: differences between dependencies and dependencymanagement
9 原子操作类之18罗汉增强
Throughput
torch.nn.functional.pad(input, pad, mode=‘constant‘, value=None)记录
841. 字符串哈希
Boot 和 Cloud 的版本选型
Make this crmeb single merchant wechat mall system popular, so easy to use!
How to cooperate among multiple threads
模拟实现string类
Equals method
Leetcode force buckle (Sword finger offer 36-39) 36 Binary search tree and bidirectional linked list 37 Serialize binary tree 38 Arrangement of strings 39 Numbers that appear more than half of the tim
R language ggplot2 visualization: use the ggecdf function of ggpubr package to visualize the grouping experience cumulative density distribution function curve, and the linetype parameter to specify t
Is PMP beneficial to work? How to choose a reliable platform to make it easier to prepare for the exam!!!
力扣 599. 两个列表的最小索引总和