当前位置:网站首页>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
边栏推荐
- 强化学习-学习笔记8 | Q-learning
- MRS离线数据分析:通过Flink作业处理OBS数据
- Equals method
- Boot 和 Cloud 的版本选型
- 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
- 注解。。。
- [confluence] JVM memory adjustment
- JVM GC garbage collection brief
- 使用高斯Redis实现二级索引
- Compiler optimization (4): inductive variables
猜你喜欢
Chapter 9 Yunji datacanvas was rated as 36 krypton "the hard core technology enterprise most concerned by investors"
Le PGR est - il utile au travail? Comment choisir une plate - forme fiable pour économiser le cœur et la main - d'œuvre lors de la préparation de l'examen!!!
8 CAS
Automatic classification of defective photovoltaic module cells in electroluminescence images-论文阅读笔记
小试牛刀之NunJucks模板引擎
vulnhub之school 1
关于cv2.dnn.readNetFromONNX(path)就报ERROR during processing node with 3 inputs and 1 outputs的解决过程【独家发布】
LeetCode_7_5
RESTAPI 版本控制策略【eolink 翻译】
9 原子操作类之18罗汉增强
随机推荐
LeetCode_ 7_ five
力扣 599. 两个列表的最小索引总和
华南X99平台打鸡血教程
The DBSCAN function of FPC package of R language performs density clustering analysis on data, checks the clustering labels of all samples, and the table function calculates the two-dimensional contin
Nunjuks template engine
vulnhub之tre1
浏览积分设置的目的
ASP.NET体育馆综合会员管理系统源码,免费分享
LeetCode力扣(剑指offer 36-39)36. 二叉搜索树与双向链表37. 序列化二叉树38. 字符串的排列39. 数组中出现次数超过一半的数字
最多可以参加的会议数目[贪心 + 优先队列]
Data island is the first danger encountered by enterprises in their digital transformation
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
模拟实现string类
多个线程之间如何协同
【Confluence】JVM内存调整
Simulate the implementation of string class
Boot 和 Cloud 的版本选型
ASP. Net kindergarten chain management system source code
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
力扣 2319. 判断矩阵是否是一个 X 矩阵