- Greedy, PostOrder Traversal, Preorder Traversal, Tree

Minimize absolute difference between sum of subtrees formed after splitting Binary tree into two

import java.lang.Math;import*;  class GFG {      static class Node {        Node left, right;        int val;        public Node(int val)        {            this.val = val;            this.left = this.right = null;        }    }                  public static…

Read More

- Binary Search Tree, Binary Search Trees, DFS, Mathematical, Recursion, Tree

Sum of all nodes with smaller values at a distance K from a given node in a BST

  #include using namespace std;  struct TreeNode {      int data;    TreeNode* left;    TreeNode* right;          TreeNode(int data)    {        this->data = data;        this->left = NULL;        this->right = NULL;    }};  void kDistanceDownSum(TreeNode* root,                      int k, int&…

Read More