[Leetcode] Longest Valid Parentheses @Python - Sumnous's Blog: " if s == '' or s == '(' or s == ')':
return 0
stack = [(-1, ')')]
maxLen = 0
for i in xrange(len(s)):
if s[i] == ')' and stack[-1][1] == '(':
stack.pop()
maxLen = max(maxLen, i - stack[-1][0])
else:
stack.append((i, s[i]))
return maxLen"
'via Blog this'
Blog Archive
-
▼
2014
(190)
-
▼
September
(29)
- [Leetcode] Longest Valid Parentheses @Python - Sum...
- 霸气侧漏的在读博士
- Programming Interview Questions
- temp
- InstallingANewHardDrive - Community Help Wiki
- Clustering With K-Means in Python | The Data Scien...
- LeetCode题解整理版(二) | Coding 4 Fun
- [leetcode]Simplify Path @ Python - 南郭子綦 - 博客园
- [leetcode]Implement strStr() @ Python - 南郭子綦 - 博客园
- [leetcode]Valid Palindrome @ Python - 南郭子綦 - 博客园
- [leetcode]Copy List with Random Pointer @ Python -...
- [leetcode]Swap Nodes in Pairs @ Python - 南郭子綦 - 博客园
- [leetcode]Remove Nth Node From End of List @ Pytho...
- [leetcode]Add Two Numbers @ Python - 南郭子綦 - 博客园
- [leetcode]Rotate List @ Python - 南郭子綦 - 博客园
- [leetcode]Plus One @ Python - 南郭子綦 - 博客园
- [leetcode]Valid Sudoku @ Python - 南郭子綦 - 博客园
- How to Read Linux Top Command Output and Uses - Te...
- [leetcode]Valid Sudoku @ Python - 南郭子綦 - 博客园
- Dropped iphone 5 in water. Help? | Apple Support C...
- [leetcode]Permutation Sequence @ Python - 南郭子綦 - 博客园
- C++11 improvements over C++03
- K-means算法及k-means++、SVD的优化 - 推酷
- Programming Interview Questions
- 统计学习笔记(2)——感知机模型 - Liam Q的专栏 - 博客频道 - CSDN.NET
- 科学网—[转载]常见面试之机器学习算法思想简单梳理 - 李建扣的博文
- soulmachine/machine-learning-cheat-sheet
- 美国一类优先移民EB1A
- c++ - Compiling C++11 with g++
-
▼
September
(29)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment