Computer Science

Leetcode 94: Binary Tree Inorder Traversal

Question: https://leetcode.com/problems/binary-tree-inorder-traversal/ Solution: class Solution { List<Integer> result = new ArrayList<>(); public List<Integer> inorderTraversal(TreeNode root) { traverse(root); return result; }…

Latest Posts

Leetcode 94: Binary Tree Inorder Traversal

Question: https://leetcode.com/problems/binary-tree-inorder-traversal/ Solution: class Solution { List<Integer> result = new ArrayList<>(); public List<Integer> inorderTraversal(TreeNode root)…

Leetcode 226: Invert Binary Tree

Question: https://leetcode.com/problems/invert-binary-tree/ Solution: class Solution { public TreeNode invertTree(TreeNode root) { if (root == null)…

Leetcode 617: Merge Two Binary Trees

Question: https://leetcode.com/problems/merge-two-binary-trees/description/ Solution: class Solution { public TreeNode mergeTrees(TreeNode root1, TreeNode root2) { if (root1…

Leetcode 1379: Find a Corresponding Node of a Binary Tree in a Clone of That Tree

Question: https://leetcode.com/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/description/ Solution: class Solution { public final TreeNode getTargetCopy(final TreeNode original, final TreeNode cloned,…

Leetcode 938: Range Sum of BST

Question: https://leetcode.com/problems/range-sum-of-bst/description/ class Solution { int result = 0; public int rangeSumBST(TreeNode root, int low,…

Press ESC to close