当前位置:网站首页>20. Valid brackets
20. Valid brackets
2022-07-03 12:11:00 【zwanying】
- Valid parenthesis
Given one only includes ‘(’,’)’,’{’,’}’,’[’,’]’ String s , Determines whether the string is valid .
Valid string needs to meet :
Opening parentheses must be closed with closing parentheses of the same type .
The left parenthesis must be closed in the correct order .
analysis :
This problem looks quite simple , Just use stack to realize . Who ever thought that one would , Do it wrong .
1、stack Methods :
Push :push(Object o)
Out of the stack :pop()
Get stack top element :peek()
Sentenced to empty :empty() No isEmpty()
2、String Methods
Traverse :
char s.charAt();
String s.substring(i,i+1);
substring It's all lowercase
The first parameter , The starting position , from 0 rise ; The second parameter , Termination position , It doesn't contain .
3、 Judge . Put left parentheses in the stack , A right bracket matches the left bracket at the top of the stack , Then the element at the top of the stack will be released . otherwise , Traverse element stack .
边栏推荐
- Colleagues wrote a responsibility chain model, with countless bugs
- 《剑指offer 03》数组中重复的数字
- 网络通讯之Socket-Tcp(一)
- Download address and installation tutorial of vs2015
- php 获取文件夹下面的文件列表和文件夹列表
- Qt OpenGL 纹理贴图
- Qt+vtk+occt reading iges/step model
- Redis 笔记 01:入门篇
- QT OpenGL rotate, pan, zoom
- Interview experience in summer camp of Central South University in 2022
猜你喜欢
Symlink(): solution to protocol error in PHP artisan storage:link on win10
Qt+vtk+occt reading iges/step model
vulnhub之Ripper
牛牛的组队竞赛
Talk about the state management mechanism in Flink framework
Why can't my MySQL container start
Shutter widget: centerslice attribute
Wrong arrangement (lottery, email)
OpenGL 绘制彩色的三角形
Duplicate numbers in the array of sword finger offer 03
随机推荐
Dart: about grpc (I)
(数据库提权——Redis)Redis未授权访问漏洞总结
vulnhub之GeminiInc
During FTP login, the error "530 login incorrect.login failed" is reported
Notes on 32-96 questions of sword finger offer
Why can't my MySQL container start
【mysql专项】读锁和写锁
Niuniu's team competition
OpenGL 索引缓存对象EBO和线宽模式
Fluent: Engine Architecture
vulnhub之tomato(西红柿)
Introduction to the implementation principle of rxjs observable filter operator
Itext7 uses iexternalsignature container for signature and signature verification
Qt OpenGL 旋转、平移、缩放
(構造筆記)從類、API、框架三個層面學習如何設計可複用軟件實體的具體技術
vulnhub之Nagini
Solution to the second weekly test of ACM intensive training of Hunan Institute of technology in 2022
DEJA_ Vu3d - 054 of cesium feature set - simulate the whole process of rocket launch
C language improvement article (wchar_t) character type
PHP导出word方法(一phpword)