当前位置:网站首页>Identify some positions in the parenthesis sequence
Identify some positions in the parenthesis sequence
2022-07-23 20:51:00 【Park Xiaoming】
link :C. Recover an RBS
The question :
Given the bracket sequence , Some of these locations are unknown , If these unknown locations can determine what to fill , It would be YES, otherwise NO.
practice :
cnt Statistical question mark ? The number of ,sum Is the number of left parentheses - Number of right parentheses . When sum + cnt == 1 when , It can be determined that cnt individual ? All for (. At this time, you just need to empty cnt, And then let sum = 1.
Last , If cnt == sum, Explain the final remaining cnt individual ? It has to be for ), That is, you can output YES 了 .
Code :
void solve()
{
string s;
cin >> s;
int cnt = 0, sum = 0;
for (auto i : s)
{
if (i == '(') sum++;
else if (i == ')') sum--;
else cnt++;
if (cnt + sum == 1)
{
cnt = 0;
sum = 1;
}
}
if (sum == cnt) cout << "YES\n";
else cout << "NO\n";
}
边栏推荐
- 游戏服务器中的排行榜设计
- LeetCode热题 HOT52-100
- 三层交换机配置MSTP协议详解【华为eNSP实验】
- Chapter 3 business function development (creating clues)
- Interpretation of Flink catalog
- 支付宝常用接口统一封装,可直接支付参数使用(适用于H5、PC、APP)
- Install under win7-vs2012 Net framework work
- Day 11: continue the basic configuration of BGP for day 10
- 《迷失》stray工人帽子获得方法 工人安全帽在哪里?
- The instructions on Microsoft website about opening or closing smartscreen in edge browser are incorrect
猜你喜欢

【持续更新】树莓派启动与故障系列集锦

Tropomi (sentinel 5p) data introduction and download method

【攻防世界WEB】难度四星12分进阶题:Confusion1

NLP领域历史最全必读经典论文分类整理分享(附中文解析)

STM32c8t6驱动激光雷达(一)

CDR插件开发之Addon插件002 - 用1分钟编写一个可双击运行的EXE程序

MySQL(3)

Car rental vehicle management system based on jsp+ssm+mysql car rental

视觉slam学习|基础篇01

TROPOMI(哨兵5P)数据介绍及下载方法
随机推荐
Detailed explanation of MSTP protocol for layer 3 switch configuration [Huawei ENSP experiment]
Lingo basic use
win7-vs2012下安装.net frame work 的过程图文详解
MySQL(3)
使用TinkerPop框架对GDB增删改查
AB team score flow chart, get the names of the players who score three consecutive times and the names of the players who catch up with and surpass the opponents each time (PDD)
对接湖南CA使用U_KEY登录
一道golang中关于for range常见坑的面试题
1061 Dating
一文读懂研发效能洞察的五大流动指标
【复数 重载运算符】
-2021最新对比学习(Contrastive Learning)相关必读论文整理分享
Educational Codeforces Round 132 A-D题解
zfoo中的providers和consumers标签
1062 Talent and Virtue
实践数据湖iceberg 第三十七课 kakfa写入iceberg的 icberg表的 enfource ,not enfource测试
Is the link of Huatai Securities' low commission account opening safe? How to handle low commission
[leetcode] day101 rotating image
LU_ASR01语音模块使用
[100 cases of scratch drawing] Figure 46-scratch drawing flowers children's programming scratch programming drawing case tutorial grade examination competition drawing training case