当前位置:网站首页>leetcode 32. 最长有效括号
leetcode 32. 最长有效括号
2022-07-22 10:17:00 【henujolly】
class Solution {
public:
int longestValidParentheses(string s) {
stack<int>q;
int maxx=0;
q.push(-1);
for(int i=0;i<s.size();i++){
if(s[i]=='('){
q.push(i);
}
else{
q.pop();
if(q.empty()){
q.push(i);
}
else maxx=max(maxx,i-q.top());
}
}
return maxx;
}
};
边栏推荐
- Firewall CMD common operation commands
- Solve couldn't determine repo type for URL
- It is found that the MariaDB database is 12 hours late, and the xxljob scheduled task scheduling is abnormal
- ZABBIX server downtime report "\u zbx\u mem\u malloc(): out of memory (requested 96 bytes)"
- C语言程序设计代码
- oracle用一条sql查出哪些数据不在某个表里
- JVM-jstat(虚拟机统计信息监视工具)的使用
- spinning
- C# DataGridView绑定数据源的几种常见方式
- getchar的使用
猜你喜欢
system表空间用满解决
shell script “<< EOF”我的用途和遇到的问题
Spark SQL 内置函数和自定义函数UDF
AForge "failed to load the file or assembly" aforge.video.ffmpeg.dll "or one of its dependencies. The specified module cannot be found "
Mysql之一主多从复制
作为初学者,我表示不想使用ESLint
Datablau5.0数据资产管理产品系列重磅发布
Ci24r1 low-cost 2.4G wireless transceiver chip replaces xn297 compact si24r1
How Oracle converts strings into multiple lines
MYSQL5.7的安装(yum、二进制、编译安装)
随机推荐
数据湖(十八):Flink与Iceberg整合SQL API操作
安装mariadb 10.5.7(tar包安装)
C regular expression extracts the index position where the specified word appears
JVM jhat (virtual machine heap dump snapshot analysis tool)
shell脚本
Zabbix Server宕机报“__zbx_mem_malloc(): out of memory (requested 96 bytes)”
微服务——Eruka
promise
Modify the contents of /etc/crontab file directly, and the scheduled task will not take effect
NewSQL数据库数据模型设计
nacos权限与数据库
作为初学者,我表示不想使用ESLint
Datablau5.0 data asset management product series heavy release
Spark RDD算子:RDD分区,HashPartitioner、RangePartitioner、自定义分区
How can ZABBIX customize MySQL monitoring items and trigger alarms
maxscale的causal_reads参数
文献记录(part109)--Self-Representation Based Unsupervised Exemplar Selection in a Union of Subspaces
纯函数与高阶函数
How Oracle converts strings into multiple lines
Typora下载和简单使用教程