当前位置:网站首页>Valid parentheses
Valid parentheses
2022-06-22 22:40:00 【Douglas_ LT】
A daily topic ing, Today is a simple question Power button 20. Valid Parentheses
class Solution {
public:
bool isValid(string s) {
int stack[10010];
memset(stack,0,10010);
int i=0,j=-1;
while(i<s.length()&&j<10000)
{
if(s[i]=='('||s[i]=='['||s[i]=='{')
{
stack[++j]=s[i];
}
if(s[i]==')')
{
if(j<0||stack[j]!='(')
return false;
j--;
}
if(s[i]==']')
{
if(j<0||stack[j]!='[')
return false;
j--;
}
if(s[i]=='}')
{
if(j<0||stack[j]!='{')
return false;
j--;
}
i++;
}
if(j!=-1)
return false;
return true;
}
};
边栏推荐
- Solve the problem that MySQL in phpstudy cannot be started and conflicts with locally installed MySQL
- Crud+ form verification for spa project development
- 【论文解读】关于基于视觉无人机自主降落平台的论文梳理
- [path planning] week 1: hodgepodge
- KDD'22 | 阿里: 基于EE探索的精排CTR预估
- R language data preprocessing, converting type variables into factor variables, converting data sets into H2O format, and dividing data sets (training set, test set, verification set)
- 组合总数[标准回溯 + 回溯技巧--降低栈深度]
- Generate detailed API and parameters of QR code using qrcodejs2
- 【路径规划】第一周: 大杂烩
- 注意|24日截止 2022年广东二级造价工程师准考证打印入口开通
猜你喜欢

What are the methods of software stress testing and how to select a software stress testing organization?

新捷途X70S上市8.79万起,空间安全越级,不愧是网红国民大7座SUV

How to use the data dictionary function in the low code platform of the Internet of things?

Reinforcement learning weekly (issue 50): saferl kit, gmi-drl, rp-sdrl & offline meta reinforcement learning

Note: by the end of 2022, the printing entrance of Guangdong second-class cost engineer's admission card has been opened
![Total number of combinations [standard backtracking + backtracking techniques -- reducing stack depth]](/img/88/3a07589bf8edab618139b1bf1680e8.png)
Total number of combinations [standard backtracking + backtracking techniques -- reducing stack depth]

Eureka service registration and discovery

RapidEye快鸟、SPOT卫星遥感影像数据

SPA项目开发之登录注册

LinkedList source code analysis
随机推荐
Case 2 of SQL performance degradation caused by modifying implicit parameters
How to use the data dictionary function in the low code platform of the Internet of things?
Delphi SOAP WebService 服务器端多个 SoapDataModule 要注意的问题
Wechat applet batch submission for review
Redis distributed lock
Lua -- iterator, module, meta table
NiO copy file call getchannel method transferfrom()
What are the indicators, dimensions and models in Business Intelligence BI data warehouse?
Generate detailed API and parameters of QR code using qrcodejs2
Query es page subscript exceeds 10000
SQL performance optimization method for interval retrieval
How to quickly build an enterprise knowledge base at low cost?
How to carry out encryption protection for equipment under extortion virus rampant
Liunx installing MySQL
Es total number of data queried by criteria
【几何法视觉】4.2 分段线性变换
Las point cloud create mesh
Mysql8 installation and environment configuration
CYCA少儿形体礼仪 深圳市培训成果考核圆满落幕
[ongoing update...] 2021 National Electronic Design Competition for college students (III) interpretation of the anonymous four axis space developer flight control system design