DIFF.BLOG
New
Following
Discover
Jobs
More
Suggest a blog
Upvotes plugin
Report bug
Contact
About
Sign up  
2022-10-09-856-括号的分数
1
·
zhuba-Ahhh
·
Oct. 9, 2022, 9:44 a.m.
Summary
856.括号的分数TS123456789101112131415161718192021222324function scoreOfParentheses(S: string): number { const stack = []; for (let i = 0; i < S.length; i++) { if (S[i] === '(') { stack.push('('); } if (S[i] === ')') { if (stack[stack.length - 1] === '(') { stack.pop(); stack.push(1); } else { let a = stack.pop(), temp = 0; while(a !== '(') { temp += a; ...
Read full post on www.zhuba.cloud →
Submit
AUTHOR
RECENT POSTS FROM THE AUTHOR