Created
August 6, 2017 02:30
-
-
Save cixuuz/0a13a532c7e834e0bc98b9d401bc5a75 to your computer and use it in GitHub Desktop.
[653. Two Sum IV - Input is a BST] #leetcode
This file contains hidden or 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
class Solution: | |
cor = set() | |
def findTarget(self, root, k): | |
""" | |
:type root: TreeNode | |
:type k: int | |
:rtype: bool | |
""" | |
if root is None: | |
return False | |
if root.val in self.cor: | |
return True | |
else: | |
self.cor.add(k - root.val) | |
return self.findTarget(root.left, k) or self.findTarget(root.right, k) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment