Aug 3, 2025 · 3 min read · Problem You're given a binary tree. Your task is to find the size of the largest subtree within this binary tree that also satisfies the properties of a Binary Search Tree (BST). The size of a subtree is defined as the number of nodes it contains. (l...
Join discussionJul 27, 2025 · 2 min read · Problem Given the root of a binary search tree and an integer k, return true if there exist two elements in the BST such that their sum is equal to k, or false otherwise. (link) Example 1: Input: root = [5,3,6,2,4,null,7], k = 9 Output: true Examp...
Join discussionJul 27, 2025 · 2 min read · Problem According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself).” Example 1: ...
Join discussionJul 26, 2025 · 2 min read · Problem Statement Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST. Basically, the deletion can be divided into two stages: Search for a node ...
Join discussionJul 25, 2025 · 2 min read · Problem Statement You are given the root of a binary search tree (BST) and an integer val. Find the node in the BST that the node's value equals val and return the subtree rooted with that node. If such a node does not exist, return null. (Link) Exam...
Join discussionFeb 21, 2025 · 1 min read · 1. Basics Search an element Ceil of an element Floor of an element Insert an element Delete an element 2. Medium Find K-th smallest/largest element in BST Check if a tree is a BST or BT LCA in Binary Search Tree Construct a BST from a pre...
Join discussionFeb 3, 2025 · 2 min read · 1. Tree Traversal Techniques Inorder Traversal (Recursive, Iterative) Preorder Traversal (Recursive, Iterative) Postorder Traversal (Recursive, Iterative) Level Order Traversal (BFS Approach) Zigzag Level Order Traversal Boundary Traversal of B...
Join discussionDec 8, 2024 · 6 min read · Welcome to Day 20 of my 100 Days of DSA challenge! Today, I solved five problems focused on basics of binary trees. Here's a quick look at the questions I tackled and how I approached them 🤖✨ Check out my GitHub repository for all my solutions and p...
Join discussionDec 1, 2024 · 19 min read · Introduction Binary Search Trees (BSTs) are a specialized form of binary trees designed to optimize the searching process. While a standard binary tree offers no inherent structure to facilitate faster lookups, BSTs introduce a pivotal property: for...
Join discussion