Session 32: Amit Postponed

Original Session

Date: 18 Jan 2025

Topic: Binary and LinkedList

Concept:

Programs

  1. 114. Flatten Binary Tree to Linked List
    1. leetcode here
    class Solution {
        public void flatten(TreeNode root) {
    
            helper(root);
        }
    
        TreeNode helper(TreeNode root) {
    
            if (root == null) {
                return root;
            }
    
            if (root.left == null && root.right == null) {
                return root;
            }
    
            TreeNode left = helper(root.left);
            TreeNode right = helper(root.right);
    
            if (left != null) {
                left.right = root.right;
                root.right = root.left;
                root.left = null;
            }
    
            return right == null ? left : right;
        }
    }

  1. HomeWork
    2130. Maximum Twin Sum of a Linked List
    328. Odd Even Linked List
    2095. Delete the Middle Node of a Linked List
    450. Delete Node in a BST
    700. Search in a Binary Search Tree
    1161. Maximum Level Sum of a Binary Tree
    2300. Successful Pairs of Spells and Potions
    875. Koko Eating Bananas