I am getting below error
name i is not defined at line i += 1
I tried putting at class Solution level. Getting same error
class Solution:
def kthSmallest(self, root: TreeNode, k: int) -> int:
i = 0
def inOrder(root):
global i
if root == None:
return
inOrder(root.left)
i += 1
if i == k:
return
inOrder(root.right)
inOrder(root)
return i