We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b79c7a0 commit 1abe274Copy full SHA for 1abe274
BT_InOrder_Traversal/RecursiveSolution.py
@@ -0,0 +1,26 @@
1
+##==================================
2
+## Leetcode
3
+## Student: Vandit Jyotindra Gajjar
4
+## Year: 2020
5
+## Problem: 94
6
+## Problem Name: Binary Tree Inorder Traversal
7
+##===================================
8
+#
9
+#Given a binary tree, return the inorder traversal of its nodes' values.
10
11
+#Example:
12
13
+#Input: [1,null,2,3]
14
+# 1
15
+# \
16
+# 2
17
+# /
18
+# 3
19
20
+#Output: [1,3,2]
21
+#Follow up: Recursive solution is trivial, could you do it iteratively?
22
+class Solution:
23
+ def inorderTraversal(self, root):
24
+ if root is None: #If root is empty
25
+ return [] #Return empty list
26
+ return self.inorderTraversal(root.left) + [root.val] + self.inorderTraversal(root.right) #Return inorder traversal
0 commit comments