当前位置:网站首页>LeetCode_ 20 (brackets match)
LeetCode_ 20 (brackets match)
2022-06-10 14:25:00 【***】
Title Description : Given one only includes ‘(’,‘)’,‘{’,‘}’,‘[’,‘]’ String s , Determines whether the string is valid .
Valid string needs to meet :
1、 Opening parentheses must be closed with closing parentheses of the same type .
2、 The left parenthesis must be closed in the correct order .
Example 1:
Input :s = “()”
Output :true
Example 2:
Input :s = “()[]{}”
Output :true
Example 3:
Input :s = “(]”
Output :false
Example 4:
Input :s = “([)]”
Output :false
Example 5:
Input :s = “{[]}”
Output :true
Tips :
1 <= s.length <= 104
s Brackets only ‘()[]{}’ form
class Solution {
public boolean isValid(String s) {
int length=s.length()/2;
for(int i=0;i<length;i++){
// Will encounter () or 【】 or {
} Eliminate it all like music
s=s.replace("()","").replace("[]","").replace("{}","");
}
return s.length()==0;
}
}
边栏推荐
- 焱融看|混合云环境下,如何实现数据湖最优存储解决方案
- 2022广东省安全员A证第三批(主要负责人)考试练习题及在线模拟考试
- 什么是CAS 以及 CAS 中的 ABA 问题
- Singleton pattern and special class design
- 几种方式可以实现 JMeter 参数化?
- Flutter 页面跳转 传参,TabBar学习总结5
- How to build Haojing technology when the computing power network is brought into reality?
- 【离散数学期复习系列】四、图
- 竟然还有人说ArrayList是2倍扩容,今天带你手撕ArrayList源码
- 消息中间件的消费模式
猜你喜欢

Still saying that university rankings are a joke? The latest regulation: Top50 universities in the world can be directly settled in Shanghai!

【解决】每次加载已经训练好的模型,生成的向量会有不同
![[discrete mathematics review series] v. some special charts](/img/4d/a52ba801b0421245d5e3828defc96d.png)
[discrete mathematics review series] v. some special charts

Flutter listview, column, row learning personal summary 2

Beijing / Shanghai internal promotion | recruitment of full-time interns in the system and network group of Microsoft Research Asia

C#多线程学习笔记三

焱融看|混合云环境下,如何实现数据湖最优存储解决方案

2022 practice questions and online simulation test for the third batch of Guangdong Provincial Safety Officer a certificate (principal)

初学者自己搭建博客的设计工具和技巧

SIGIR 2022 | 港大、武大提出KGCL:基于知识图谱对比学习的推荐系统
随机推荐
Flutter 页面跳转 传参,TabBar学习总结5
2022年危险化学品生产单位安全生产管理人员考试模拟100题及在线模拟考试
博主自白
How to build Haojing technology when the computing power network is brought into reality?
Is it safe to open an account in qiniu
Adding, deleting, modifying and querying databases with JDBC
22.6.7 successfully use doc2vec model to generate embedded vectors
C multithreading learning note 3
Basic concept of data warehouse
[original] poi 5 X xssf and HSSF use custom font colors
Yanrong looks at how to realize the optimal storage solution of data Lake in a hybrid cloud environment
[big guy show] aiops in the eyes of Borui data, choosing the right track and the right people
Primary master-slave table integration process development process
How can JMeter parameterization be implemented?
为doc2vec生成训练向量的数据集
2022广东省安全员A证第三批(主要负责人)考试练习题及在线模拟考试
[logodetection data set processing] (3) divide the training set into multiple folders by category
anaconda安装opencv(cv2),在jupyter notebook中使用
【Vue/js】通过localStorage浏览器实现变量和对象的本地缓存(图文+完整源代码)
jdbc对数据库增删改查