Skip to content

Instantly share code, notes, and snippets.

@kunal768
Created May 20, 2020 12:49
Show Gist options
  • Save kunal768/dfb93957c156be757da3011fec0e09a8 to your computer and use it in GitHub Desktop.
Save kunal768/dfb93957c156be757da3011fec0e09a8 to your computer and use it in GitHub Desktop.
class Solution:
def kthSmallest(self, root: TreeNode, k: int) -> int:
arr = []
def inorder(root,arr):
if root.left :
inorder(root.left,arr)
if root :
arr.append(root.val)
if root.right :
inorder(root.right,arr)
inorder(root,arr)
return arr[k-1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment