Test cases passes individually, but when submitted, the first Output just stays in the list.
Cant wrap my head around it. What is happening?
class Solution:
l=[]
def inorderTraversal(self, root: TreeNode) -> List[int]:
if root is None:
return self.l
else:
if root.left:
self.inorderTraversal(root.left)
self.l.append(root.val)
if root.right:
self.inorderTraversal(root.right)
return self.l
***Test Case***
> Your input [1]
Output [1]
Expected [1]
**Submitted**
> Wrong Answer Details
Input []
Output [1,3,2]
Expected []