We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
关键:找到最外层的起始位置,通过字符串方法 substring获取原语
substring
var removeOuterParentheses = function(S) { // 关键:找到最外层的起始位置 let flag = 0, result = '', start = 0; for(let i = 0; i < S.length; i++) { if (S[i] === '(') { flag++; } else { // flag--; // 等于0,说明就是最外层的括号 if (--flag === 0) { // console.log(start, i); result += S.substring(start + 1, i); // 设置下一个开始的起点 start = i + 1; } } } return result; };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
1021. 删除最外层的括号
思路
关键:找到最外层的起始位置,通过字符串方法
substring
获取原语The text was updated successfully, but these errors were encountered: