Submission Detail

93 / 93 test cases passed.
Status:

Accepted

Runtime: 23 ms
Memory Usage: 13.6 MB
Submitted: 1 week, 1 day ago
loading
Runtime Error Message:
Last executed input:
Input:
Output:
Expected:

Accepted Solutions Runtime Distribution

0
5
10
15
20
25
30
35
40
45
2.5
5.0
7.5
10.0
12.5
python
You are here!
Your runtime beats 30.60 % of python submissions.
Runtime (ms)
Distribution (%)

0
5
10
15
20
25
30
35
40
45
5
10
Zoom area by dragging across this chart

Accepted Solutions Memory Distribution

13300
12900
13000
13100
13200
13400
13500
13600
13700
5
10
15
20
25
30
35
python
You are here!
Your memory usage beats 16.93 % of python submissions.
Memory (KB)
Distribution (%)

13300
12900
13000
13100
13200
13400
13500
13600
13700
10
20
30
Zoom area by dragging across this chart

Invite friends to challenge Valid Parentheses


Submitted Code: 1 week, 1 day ago

Language: python

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class Solution(object):
def isValid(self, s):
"""
:type s: str
:rtype: bool
"""
stack = []
for c in s:
if (c == '('):
stack.insert(0,c)
if (c == '{'):
stack.insert(0,c)
if (c == '['):
stack.insert(0,c)
if (c == ')'):
if (len(stack) < 1):
return False
if (stack[0] == '('):
stack.pop(0)
else:
return False
if (c == '}'):
if (len(stack) < 1):
return False
if (stack[0] == '{'):
stack.pop(0)
else:
return False
if (c == ']'):
if (len(stack) < 1):
return False
if (stack[0] == '['):
stack.pop(0)
else:
return False
if (len(stack) > 0):
return False
return True
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX