[JAVA] Easy Tree Hieght solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\n/**\n * Definition for a binary tree node.\n * public class TreeNode {\n *     int val;\n *     TreeNode left;\n *     TreeNode right;\n *     TreeNode() {}\n *     TreeNode(int val) { this.val = val; }\n *     TreeNode(int val, TreeNode left, TreeNode right) {\n *         this.val = val;\n *         this.left = left;\n *         this.right = right;\n *     }\n * }\n */\nclass Solution {\n    public int kthLargestPerfectSubtree(TreeNode root, int k) {\n        List<Integer> l1 = new ArrayList<>();\n        hieght(root,l1);\n        if (k <= 0 || k > l1.size()) {\n            return -1; // Return -1 if k is out of bounds\n        }\n        Collections.sort(l1, Collections.reverseOrder()); // Sort in descending order\n        int h = l1.get(k - 1);\n        int ans = (int)Math.pow(2,h)-1;\n        return ans;\n    }\n\n    public int hieght(TreeNode root,List<Integer> l1 ){\n        if (root==null){\n            return 0;\n        }\n       \n        int lh = hieght(root.left,l1);\n        int rh = hieght(root.right,l1);\n\n        if(lh>-1 && lh==rh){\n            l1.add(lh+1);\n        }else{\n            return -1;\n        }\n\n        return Math.max(lh,rh)+1;\n    }\n}\n```
['Binary Tree', 'Java']