Skip to content

Commit 57bd1a7

Browse files
authored
Merge pull request #1242 from ivan1016017/april16
adding algo
2 parents c1bf36b + 1f9f95b commit 57bd1a7

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from typing import List, Union, Collection, Mapping, Optional
2+
from abc import ABC, abstractmethod
3+
4+
class Solution:
5+
def isValid(self, s):
6+
7+
dic_parentheses = {'(':')','[':']','{':'}'}
8+
check_list = list()
9+
10+
for p in s:
11+
if p in dic_parentheses:
12+
check_list.append(p)
13+
else:
14+
if len(check_list) == 0 \
15+
or p != dic_parentheses[check_list.pop()]:
16+
return False
17+
18+
return len(check_list) == 0

tests/test_150_questions_round_15/test_valid_parentheses_round_15.py

Whitespace-only changes.

0 commit comments

Comments
 (0)