Find all paths in a binary tree which sum upto value

Problem You are given a binary tree in which each node contains a value. Design an algorithm to print all paths which sum up to that value. Note that it can be any path in the tree – it does not have to start at the root. Examples Example 1: 10 / \ 7 15 / \ / \ 8 9 11 1 ...

Linked List in Binary Tree Problem

Problem Given a binary tree root and a linked list with head as the first node. Return True if all the elements in the linked list starting from the head correspond to some downward path connected in the binary tree otherwise return False. In this context downward path means a path that starts at some node and goes downwards. Examples Example 1: ...

Leaf-Similar Trees Problem

Problem Consider all the leaves of a binary tree, from left to right order, the values of those leaves form a leaf value sequence. graph TD; A(3) --- B(5) & C(1) B --- D(6) & E(2) E --- F(7) & G(4) C --- H(9) & I(8) style D fill:#4682B4,stroke:#333,stroke-width:2px style F fill:#4682B4,stroke:#333,stroke-width:2px style G fill:#4682B4,stroke:#333,stroke-width:2px style H fill:#4682B4,stroke:#333,stroke-width:2px style I fill:#4682B4,stroke:#333,stroke-width:2px ...

Trim a Binary Search Tree BST

Problem Given the root of a binary search tree and the lowest and highest boundaries as low and high, trim the tree so that all its elements lies in [low, high]. Trimming the tree should not change the relative structure of the elements that will remain in the tree (i.e., any node’s descendant should remain a descendant). It can be proven that there is a unique answer. Return the root of the trimmed binary search tree. Note that the root may change depending on the given bounds. ...

This site uses cookies to improve your experience on our website. By using and continuing to navigate this website, you accept this. Privacy Policy