Day 18 Daily LeetCode challenge problem || JAVA || O(N) || Recursion ||
APPROACH:  O(N) time and O(1) space\n\n Traverse the tree in inorder fashion, and on each function frame increase kth variable.\n Inorder gives the sorted order
APPROACH:  O(N) time and O(1) space\n\n* Traverse the tree in inorder fashion, and on each function frame increase kth variable.\n* Inorder gives the sorted order.\n* when kth variable become equal to k that means we got our ans (i.e kth smallest element )\n* O(1) space.\n* O(N) time.\n\n### **JAVA**\n\n```\n\nclass Solution {\n\n    static int kth=0;\n   \n    static int kthsmall=0;\n\n   public int kthSmallest(TreeNode root, int k) {\n    \n\t    kth=0;\n        kthsmall=0;\n        \n        inorder(root,k);\n        \n        return ans;\n    }\n    \n    public static void inorder(TreeNode root,int k){\n        \n        if(root==null){\n            return ;\n        }        \n        \n        inorder(root.left,k);\n        \n        kth++;\n        if(kth==k){\n            kthsmall=root.val;\n        }\n        \n        inorder(root.right,k);     \n    }\n}\n\t\n```
['Depth-First Search', 'Breadth-First Search', 'Java']