-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
delete week03, and refactor according to tags
- Loading branch information
Showing
8 changed files
with
81 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,3 +40,10 @@ def swapPairs(self, head): | |
else: | ||
break | ||
return result.next | ||
|
||
""" | ||
[] | ||
[1] | ||
[1,2,3] | ||
[1,2,3,4,5,6] | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#! /usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
|
||
class Solution(object): | ||
def isValid(self, s): | ||
""" | ||
:type s: str | ||
:rtype: bool | ||
""" | ||
parenthes_stack = [] | ||
match_rule = {")": "(", "]": "[", "}": "{"} | ||
for symble in s: | ||
if symble == "(" or symble == "[" or symble == "{": | ||
parenthes_stack.append(symble) | ||
|
||
else: | ||
# Check if stack top matches the current ), ] or }. | ||
if (parenthes_stack and | ||
parenthes_stack[-1] == match_rule[symble]): | ||
parenthes_stack.pop() | ||
else: | ||
return False | ||
# Have some symbles that is not matched. | ||
if parenthes_stack: | ||
return False | ||
|
||
return True | ||
|
||
""" | ||
"" | ||
"[" | ||
"()()()()[]" | ||
"()((()){})" | ||
""" |
This file was deleted.
Oops, something went wrong.