We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5583d33 commit 53fe546Copy full SHA for 53fe546
validate-binary-search-tree/sejineer.py
@@ -0,0 +1,24 @@
1
+"""
2
+시간 복잡도: O(N)
3
+공간 복잡도: O(N)
4
5
+class Solution:
6
+ def isValidBST(self, root: Optional[TreeNode]) -> bool:
7
+ num_list = []
8
+
9
+ def dfs(node: TreeNode):
10
+ if not node:
11
+ return
12
13
+ dfs(node.left)
14
+ num_list.append(node.val)
15
+ dfs(node.right)
16
17
+ dfs(root)
18
19
+ mem = num_list[0]
20
+ for i in range(1, len(num_list)):
21
+ if mem >= num_list[i]:
22
+ return False
23
+ mem = num_list[i]
24
+ return True
0 commit comments