LeetCodechevron_rightCategorieschevron_righttree
account_tree

tree

191 problems
Easy: 38Medium: 105Hard: 48

tree is one of the most repeated interview dimensions. Start with edge-safe fundamentals, then move into pattern-level trade-offs.

Interview Signal

Frequently tests problem modeling, edge handling, and verbal clarity.

Common Pitfall

Template-only answers break under follow-up questioning.

Practice Strategy

Practice in 3-5 problem rounds and always review complexity alternatives.

Recommended Progression

#TitleDifficulty
94

Binary Tree Inorder Traversal

Binary Tree Inorder Traversal asks you to visit left subtree, node, then right subtree without losing position while mov…

Easy
95

Unique Binary Search Trees II

Generate all structurally unique BSTs with values 1 to n using backtracking and recursive tree construction techniques.

Medium
96

Unique Binary Search Trees

Given n nodes, calculate the number of unique binary search trees (BSTs) that can be formed with values from 1 to n.

Medium
98

Validate Binary Search Tree

Validate Binary Search Tree problem checks if a binary tree satisfies BST properties using tree traversal and state trac…

Medium
99

Recover Binary Search Tree

Recover a BST where two nodes are swapped by mistake using in-order traversal and careful state tracking to restore corr…

Medium
100

Same Tree

Check whether two binary trees are identical by comparing structure and node values using DFS or BFS traversal strategie…

Easy
101

Symmetric Tree

Determine if a binary tree is symmetric by comparing left and right subtrees using DFS or BFS traversal techniques effic…

Easy
102

Binary Tree Level Order Traversal

Perform a level order traversal on a binary tree using BFS to return node values level by level.

Medium
103

Binary Tree Zigzag Level Order Traversal

Traverse a binary tree in zigzag level order, alternating directions at each depth using BFS and state tracking techniqu…

Medium
104

Maximum Depth of Binary Tree

Find the maximum depth of a binary tree using traversal techniques to track the longest path from root to leaf.

Easy
105

Construct Binary Tree from Preorder and Inorder Traversal

Construct a binary tree using preorder and inorder traversal arrays, leveraging array scanning and hash table lookups.

Medium
106

Construct Binary Tree from Inorder and Postorder Traversal

Reconstruct a binary tree from given inorder and postorder arrays using array scanning and hash lookup to optimize recur…

Medium
107

Binary Tree Level Order Traversal II

Return a bottom-up level order traversal of a binary tree, processing nodes left to right while tracking each level accu…

Medium
108

Convert Sorted Array to Binary Search Tree

Pick the middle element as root at each step so the sorted array becomes a height-balanced BST with valid ordering.

Easy
109

Convert Sorted List to Binary Search Tree

Convert a sorted singly linked list into a height-balanced BST using pointer manipulation and divide-and-conquer recursi…

Medium
110

Balanced Binary Tree

Determine if a binary tree is height-balanced using tree traversal and state tracking techniques.

Easy
111

Minimum Depth of Binary Tree

Find the minimum depth of a binary tree, which is the shortest path from the root node to the nearest leaf node.

Easy
112

Path Sum

Determine if a binary tree has a root-to-leaf path where the sum of node values equals a given target sum, using DFS or …

Easy
113

Path Sum II

Find all root-to-leaf paths in a binary tree where the sum of node values equals a given target using DFS backtracking.

Medium
114

Flatten Binary Tree to Linked List

Flatten a binary tree into a right-skewed linked list by manipulating pointers following a pre-order traversal, handling…

Medium
116

Populating Next Right Pointers in Each Node

Connect each node across every level by reusing established next links to traverse a perfect binary tree without extra q…

Medium
117

Populating Next Right Pointers in Each Node II

Populate each next pointer in a binary tree to its immediate right node, handling nulls and uneven levels efficiently us…

Medium
124

Binary Tree Maximum Path Sum

Calculate the maximum sum of any path in a binary tree by exploring all node sequences using DFS and dynamic programming…

Hard
129

Sum Root to Leaf Numbers

Calculate the sum of all root-to-leaf numbers in a binary tree where each path represents a number.

Medium
144

Binary Tree Preorder Traversal

Perform a binary tree preorder traversal by visiting root nodes first, then left and right subtrees, tracking state iter…

Easy
145

Binary Tree Postorder Traversal

Solve Binary Tree Postorder Traversal using state tracking and binary-tree traversal techniques, focusing on Stack, Tree…

Easy
173

Binary Search Tree Iterator

Implement an iterator for in-order traversal of a binary search tree (BST), maintaining traversal state with stack-based…

Medium
199

Binary Tree Right Side View

The Binary Tree Right Side View problem asks you to return the visible nodes from the right side of a binary tree, trave…

Medium
222

Count Complete Tree Nodes

Count Complete Tree Nodes efficiently by leveraging binary-tree traversal, exploiting completeness, and applying bit man…

Easy
226

Invert Binary Tree

Invert Binary Tree swaps every node's left and right children using tree traversal, with recursive DFS or iterative BFS …

Easy
230

Kth Smallest Element in a BST

Find the kth smallest element in a BST by leveraging in-order traversal to efficiently track node order and count.

Medium
235

Lowest Common Ancestor of a Binary Search Tree

Find the lowest common ancestor (LCA) of two nodes in a binary search tree, using binary-tree traversal and state tracki…

Medium
236

Lowest Common Ancestor of a Binary Tree

Identify the lowest common ancestor of two nodes in a binary tree using traversal and state tracking techniques efficien…

Medium
257

Binary Tree Paths

Find all root-to-leaf paths in a binary tree using DFS and backtracking, constructing strings for each complete path eff…

Easy
297

Serialize and Deserialize Binary Tree

This problem asks to serialize and deserialize a binary tree, requiring an efficient approach to handle traversal and st…

Hard
331

Verify Preorder Serialization of a Binary Tree

Determine if a given string correctly represents a binary tree preorder traversal using state tracking and slot counting…

Medium
337

House Robber III

Maximize the loot by robbing non-adjacent houses in a binary tree structure using dynamic programming and DFS.

Medium
341

Flatten Nested List Iterator

Implement an iterator to flatten a nested list of integers, accounting for potential nesting levels.

Medium
404

Sum of Left Leaves

Compute the total of all left leaves in a binary tree using precise traversal and state tracking techniques for correctn…

Easy
427

Construct Quad Tree

Construct a Quad-Tree from a binary matrix by recursively subdividing regions and tracking uniform states efficiently.

Medium
429

N-ary Tree Level Order Traversal

Perform a level order traversal on an n-ary tree, capturing nodes by depth using breadth-first search with careful state…

Medium
437

Path Sum III

Path Sum III challenges you to count paths in a binary tree that sum to a given target value with downward traversal.

Medium
449

Serialize and Deserialize BST

Design an algorithm to serialize and deserialize a binary search tree with efficient traversal and state tracking.

Medium
450

Delete Node in a BST

Delete Node in a BST hinges on removing one target while preserving in-order ordering through carefully chosen subtree r…

Medium
501

Find Mode in Binary Search Tree

Find Mode in Binary Search Tree asks to identify the most frequent element(s) in a BST using binary-tree traversal.

Easy
508

Most Frequent Subtree Sum

Identify the most frequent subtree sum in a binary tree using DFS and hash table tracking for efficient state management…

Medium
513

Find Bottom Left Tree Value

Find the leftmost value in the last row of a binary tree using efficient traversal strategies.

Medium
515

Find Largest Value in Each Tree Row

Find the largest value in each row of a binary tree using depth-first or breadth-first search techniques.

Medium
530

Minimum Absolute Difference in BST

Find the minimum absolute difference between values of any two nodes in a BST using tree traversal and careful state tra…

Easy
538

Convert BST to Greater Tree

Convert a BST into a Greater Tree by updating each node’s value with the sum of all greater values in the tree.

Medium
543

Diameter of Binary Tree

The Diameter of Binary Tree problem involves finding the longest path between any two nodes using tree traversal techniq…

Easy
558

Logical OR of Two Binary Grids Represented as Quad-Trees

Compute the logical OR of two binary matrices represented as Quad-Trees using recursive tree traversal and state propaga…

Medium
559

Maximum Depth of N-ary Tree

Find the maximum depth of an N-ary tree, leveraging tree traversal techniques and state tracking.

Easy
563

Binary Tree Tilt

Calculate the sum of the binary tree's node tilts using tree traversal and state tracking.

Easy
572

Subtree of Another Tree

Determine if one binary tree is an exact subtree of another by comparing structure and node values recursively.

Easy
589

N-ary Tree Preorder Traversal

Solve the N-ary Tree Preorder Traversal problem using depth-first search and stack-based traversal methods.

Easy
590

N-ary Tree Postorder Traversal

Postorder traversal of an N-ary tree can be efficiently solved using DFS and stack-based methods, tracking state across …

Easy
606

Construct String from Binary Tree

Given a binary tree, construct a string representation based on preorder traversal while adhering to specific formatting…

Medium
617

Merge Two Binary Trees

Merge Two Binary Trees requires combining nodes by summing overlapping values while preserving non-null nodes from eithe…

Easy
623

Add One Row to Tree

The problem requires adding a row of nodes to a binary tree at a specified depth.

Medium
637

Average of Levels in Binary Tree

Calculate the average value of nodes on each level of a binary tree using traversal and state tracking.

Easy
652

Find Duplicate Subtrees

Identify all duplicate subtrees in a binary tree by efficiently tracking structure and values with depth-first traversal…

Medium
653

Two Sum IV - Input is a BST

Determine if a binary search tree contains two nodes whose values sum to a target using efficient traversal and state tr…

Easy
654

Maximum Binary Tree

Construct a maximum binary tree by recursively selecting the largest element and dividing the array into left and right …

Medium
655

Print Binary Tree

Print Binary Tree requires arranging a binary tree into a visually structured matrix using precise traversal and positio…

Medium
662

Maximum Width of Binary Tree

Determine the maximum width of a binary tree by calculating the width of each level and considering the positions of the…

Medium
669

Trim a Binary Search Tree

Trim a Binary Search Tree by maintaining its structure while removing nodes outside a given range.

Medium
671

Second Minimum Node In a Binary Tree

Find the second minimum node in a binary tree by traversing the tree and tracking state.

Easy
687

Longest Univalue Path

Find the longest path in a binary tree where all nodes share the same value using depth-first search efficiently.

Medium
690

Employee Importance

Calculate an employee's total importance including all direct and indirect subordinates using array scanning and hash lo…

Medium
700

Search in a Binary Search Tree

Locate a target value in a binary search tree and return the subtree rooted at that node using efficient tree traversal …

Easy
701

Insert into a Binary Search Tree

Insert a value into a Binary Search Tree while maintaining the BST properties, focusing on tree traversal and state trac…

Medium
703

Kth Largest Element in a Stream

Find the kth largest element in a dynamic stream using binary-tree traversal and efficient state tracking with a min-hea…

Easy
783

Minimum Distance Between BST Nodes

Find the minimum difference between values of two different nodes in a Binary Search Tree using tree traversal and state…

Easy
814

Binary Tree Pruning

Binary Tree Pruning removes subtrees not containing a 1, applying binary-tree traversal with state tracking.

Medium
834

Sum of Distances in Tree

The problem asks to compute the sum of distances between each node and all others in a tree structure using depth-first …

Hard
863

All Nodes Distance K in Binary Tree

Find all nodes at distance K from a target node in a binary tree using various tree traversal techniques.

Medium
865

Smallest Subtree with all the Deepest Nodes

Find the smallest subtree that contains all the deepest nodes in a binary tree.

Medium
872

Leaf-Similar Trees

Determine if two binary trees have identical leaf sequences using efficient traversal and state tracking techniques.

Easy
889

Construct Binary Tree from Preorder and Postorder Traversal

Reconstruct a binary tree from preorder and postorder traversals using array scanning and hash lookup.

Medium
894

All Possible Full Binary Trees

Generate all possible full binary trees with n nodes, focusing on dynamic programming and binary tree traversal.

Medium
897

Increasing Order Search Tree

Rearrange a binary search tree so all nodes follow increasing order with only right children using in-order traversal.

Easy
919

Complete Binary Tree Inserter

Implement a data structure to insert nodes into a complete binary tree while preserving its completeness efficiently.

Medium
938

Range Sum of BST

Given a BST and a range, calculate the sum of all node values within that range.

Easy
951

Flip Equivalent Binary Trees

Determine if two binary trees are flip equivalent by recursively swapping subtrees.

Medium
958

Check Completeness of a Binary Tree

Determine if a binary tree is complete by verifying its node structure and leftmost placement in the last level.

Medium
965

Univalued Binary Tree

Determine if a binary tree is uni-valued using traversal and state tracking techniques.

Easy
968

Binary Tree Cameras

Determine the minimum number of cameras required to monitor every node in a binary tree using efficient DFS and state tr…

Hard
971

Flip Binary Tree To Match Preorder Traversal

Determine the minimum set of nodes to flip in a binary tree so its pre-order traversal matches a given voyage sequence.

Medium
979

Distribute Coins in Binary Tree

Minimize the number of moves needed to distribute coins in a binary tree so that each node has exactly one coin.

Medium
987

Vertical Order Traversal of a Binary Tree

Perform a vertical order traversal of a binary tree, sorting nodes by their values within columns.

Hard
988

Smallest String Starting From Leaf

Determine the lexicographically smallest string from a leaf to root using binary-tree traversal and careful state tracki…

Medium
993

Cousins in Binary Tree

Determine if two nodes in a binary tree are cousins by leveraging binary-tree traversal and state tracking.

Easy
998

Maximum Binary Tree II

The Maximum Binary Tree II problem requires building a binary tree by inserting a value into a maximum binary tree while…

Medium
1008

Construct Binary Search Tree from Preorder Traversal

Construct a binary search tree directly from a preorder traversal array using stack-based state tracking efficiently.

Medium
1022

Sum of Root To Leaf Binary Numbers

Calculate the sum of binary numbers from root to leaf paths in a binary tree.

Easy
1026

Maximum Difference Between Node and Ancestor

Find the maximum absolute difference between a node and its ancestor in a binary tree.

Medium
1028

Recover a Tree From Preorder Traversal

Recover a binary tree from its preorder traversal string by tracking node depth and reconstructing child relationships e…

Hard
1038

Binary Search Tree to Greater Sum Tree

Convert a Binary Search Tree to a Greater Sum Tree by accumulating all larger node values using reverse in-order travers…

Medium
1080

Insufficient Nodes in Root to Leaf Paths

Remove nodes in a binary tree whose all root-to-leaf paths sum to less than a given limit using DFS traversal and state …

Medium
1104

Path In Zigzag Labelled Binary Tree

The problem involves finding the path from the root to a node in a zigzag-labelled binary tree.

Medium
1110

Delete Nodes And Return Forest

Delete nodes from a binary tree using array scanning and hash lookup to return the remaining forest efficiently.

Medium
1123

Lowest Common Ancestor of Deepest Leaves

Find the lowest common ancestor of the deepest leaves in a binary tree using efficient traversal and state tracking tech…

Medium
1145

Binary Tree Coloring Game

A two-player game where players color nodes in a binary tree, aiming to outmaneuver each other by choosing adjacent node…

Medium
1161

Maximum Level Sum of a Binary Tree

Find the level of a binary tree where the sum of its nodes is maximal, with an emphasis on binary-tree traversal.

Medium
1261

Find Elements in a Contaminated Binary Tree

Recover values in a contaminated binary tree and efficiently check for existence using traversal and state tracking tech…

Medium
1302

Deepest Leaves Sum

Find the sum of the deepest leaves in a binary tree by using tree traversal and state tracking techniques.

Medium
1305

All Elements in Two Binary Search Trees

Merge elements from two binary search trees and return them sorted in ascending order.

Medium
1315

Sum of Nodes with Even-Valued Grandparent

This problem involves calculating the sum of nodes with an even-valued grandparent in a binary tree.

Medium
1325

Delete Leaves With a Given Value

In this problem, you need to delete all leaf nodes in a binary tree with a given target value, performing continuous del…

Medium
1339

Maximum Product of Splitted Binary Tree

Maximize the product of sums of two subtrees formed by splitting a binary tree.

Medium
1361

Validate Binary Tree Nodes

Validate Binary Tree Nodes problem requires checking if a set of nodes forms a valid binary tree using graph traversal.

Medium
1367

Linked List in Binary Tree

Determine if a linked list is represented as a downward path in a binary tree using pointer traversal and recursive chec…

Medium
1372

Longest ZigZag Path in a Binary Tree

Find the longest ZigZag path in a binary tree using depth-first search and dynamic programming for precise node state tr…

Medium
1373

Maximum Sum BST in Binary Tree

Find the maximum sum of values from any Binary Search Tree (BST) subtree in a binary tree.

Hard
1376

Time Needed to Inform All Employees

Calculate the time needed for the head of a company to inform all employees using tree traversal techniques.

Medium
1377

Frog Position After T Seconds

The problem asks for the probability that a frog reaches a target vertex after t seconds in a tree graph.

Hard
1379

Find a Corresponding Node of a Binary Tree in a Clone of That Tree

Find the corresponding node in a cloned binary tree using binary-tree traversal and state tracking.

Easy
1382

Balance a Binary Search Tree

This problem requires balancing a binary search tree using in-order traversal and state tracking techniques.

Medium
1443

Minimum Time to Collect All Apples in a Tree

Minimize the time spent to collect all apples in a tree, considering traversal and state tracking with binary tree techn…

Medium
1448

Count Good Nodes in Binary Tree

Count Good Nodes in Binary Tree identifies nodes exceeding all previous values along their path using DFS traversal tech…

Medium
1457

Pseudo-Palindromic Paths in a Binary Tree

Count all root-to-leaf paths in a binary tree that can be rearranged to form a palindrome using bitwise state tracking.

Medium
1483

Kth Ancestor of a Tree Node

Find the kth ancestor of any node in a tree using efficient binary-tree traversal and dynamic state tracking methods.

Hard
1519

Number of Nodes in the Sub-Tree With the Same Label

Compute the number of nodes in each subtree sharing the same label using DFS with hash table aggregation efficiently.

Medium
1530

Number of Good Leaf Nodes Pairs

Find the number of good leaf node pairs in a binary tree where the shortest path between them is less than or equal to a…

Medium
1569

Number of Ways to Reorder Array to Get Same BST

Determine the number of ways to reorder an array to get the same binary search tree (BST) from its insertion order.

Hard
1600

Throne Inheritance

Throne Inheritance requires modeling a dynamic family tree with births and deaths to determine the kingdom's inheritance…

Medium
1609

Even Odd Tree

Determine if a binary tree meets Even-Odd rules by checking value parity and strict ordering at each level efficiently.

Medium
1617

Count Subtrees With Max Distance Between Cities

This problem asks you to count subtrees in a tree structure where the maximum distance between any two cities matches sp…

Hard
1719

Number Of Ways To Reconstruct A Tree

Determine how many distinct rooted trees can be reconstructed from given node pairs using careful traversal and state tr…

Hard
1766

Tree of Coprimes

Determine the closest coprime ancestor for each node in a tree using efficient traversal and state tracking of node valu…

Hard
1916

Count Ways to Build Rooms in an Ant Colony

Solve the problem of counting distinct ways to build rooms in an ant colony using dynamic programming and topological or…

Hard
1932

Merge BSTs to Create Single BST

This problem asks you to merge multiple BSTs into a single valid BST by performing a series of operations.

Hard
1993

Operations on Tree

Design a tree data structure that allows locking, unlocking, and upgrading nodes with user-specific actions.

Medium
2003

Smallest Missing Genetic Value in Each Subtree

Determine the smallest missing genetic value in each subtree using binary-tree traversal and precise state tracking effi…

Hard
2049

Count Nodes With the Highest Score

Find the number of nodes with the highest score in a binary tree, based on subtree sizes and node removal.

Medium
2096

Step-By-Step Directions From a Binary Tree Node to Another

Find the shortest path between two nodes in a binary tree and output the directions as a string of 'L', 'R', and 'U'.

Medium
2196

Create Binary Tree From Descriptions

Build a binary tree from descriptions of parent-child relationships using array scanning and hash lookup.

Medium
2236

Root Equals Sum of Children

Check if a binary tree root value equals the sum of its immediate left and right child nodes efficiently.

Easy
2246

Longest Path With Different Adjacent Characters

Find the longest path in a tree where adjacent nodes have different characters using graph DFS and topological reasoning…

Hard
2265

Count Nodes Equal to Average of Subtree

Given a binary tree, count nodes where the value equals the average of values in its subtree.

Medium
2322

Minimum Score After Removals on a Tree

Compute the minimum score after removing two edges in a tree using DFS and XOR-based component tracking efficiently.

Hard
2331

Evaluate Boolean Binary Tree

Determine the boolean outcome of a full binary tree by evaluating leaf and internal nodes using depth-first traversal.

Easy
2368

Reachable Nodes With Restrictions

In the 'Reachable Nodes With Restrictions' problem, find the maximum reachable nodes from node 0 in a tree while avoidin…

Medium
2385

Amount of Time for Binary Tree to Be Infected

The problem asks to calculate the number of minutes for an infection to spread across all nodes in a binary tree startin…

Medium
2415

Reverse Odd Levels of Binary Tree

Reverse the node values at each odd level in a perfect binary tree, preserving the even levels.

Medium
2421

Number of Good Paths

Count all good paths in a tree by scanning node values and using hash maps to track valid connections efficiently.

Hard
2440

Create Components With Same Value

Maximize the number of components in a tree with equal sums by carefully deleting edges using divisor-based logic.

Hard
2458

Height of Binary Tree After Subtree Removal Queries

Compute the height of a binary tree efficiently after removing subtrees, using traversal and precomputed node state trac…

Hard
2467

Most Profitable Path in a Tree

Solve the 'Most Profitable Path in a Tree' problem using graph traversal and depth-first search techniques to maximize A…

Medium
2471

Minimum Number of Operations to Sort a Binary Tree by Level

Determine the minimum number of swaps to sort each level of a binary tree using level-wise traversal efficiently.

Medium
2476

Closest Nodes Queries in a Binary Search Tree

Solve the problem of finding closest nodes in a Binary Search Tree for multiple queries, efficiently handling each query…

Medium
2477

Minimum Fuel Cost to Report to the Capital

Calculate the minimum fuel needed for all city representatives to reach the capital using DFS on a tree graph efficientl…

Medium
2509

Cycle Length Queries in a Tree

Solve the problem of determining cycle lengths in a binary tree with added edges through queries.

Hard
2538

Difference Between Maximum and Minimum Price Sum

Compute the maximum difference between any path price sum in a tree using binary-tree traversal and state tracking effic…

Hard
2581

Count Number of Possible Root Nodes

Given a tree and a set of guesses, find how many nodes can be the root while satisfying the guess constraints.

Hard
2583

Kth Largest Sum in a Binary Tree

Find the kth largest level sum in a binary tree using level-order traversal and sorting.

Medium
2603

Collect Coins in a Tree

The "Collect Coins in a Tree" problem requires traversing a tree to collect coins in the fewest steps while returning to…

Hard
2641

Cousins in Binary Tree II

Replace each node in a binary tree with the sum of all its cousins by carefully tracking depth and parent relationships.

Medium
2646

Minimize the Total Price of the Trips

Calculate the minimum total cost of multiple trips on a tree by selectively halving node prices using DFS frequency coun…

Hard
2673

Make Costs of Paths Equal in a Binary Tree

Minimize the cost increments required to equalize path costs in a binary tree from root to leaves.

Medium
2791

Count Paths That Can Form a Palindrome in a Tree

This problem asks you to count all node pairs in a tree whose path characters can be rearranged into a palindrome using …

Hard
2846

Minimum Edge Weight Equilibrium Queries in a Tree

Find the minimum number of operations to equalize edge weights in a tree between given pairs of nodes.

Hard
2867

Count Valid Paths in a Tree

Count Valid Paths in a Tree involves finding paths with exactly one prime number in a tree of n nodes.

Hard
2872

Maximum Number of K-Divisible Components

Determine the maximum number of connected components in a tree where each component sum is divisible by k using DFS.

Hard
2920

Maximum Points After Collecting Coins From All Nodes

Find the maximum points after collecting coins from all nodes of a tree using binary-tree traversal and state tracking.

Hard
2925

Maximum Score After Applying Operations on a Tree

Solve Maximum Score After Applying Operations on a Tree by turning healthy-path constraints into subtree DP and forced-v…

Medium
2973

Find Number of Coins to Place in Tree Nodes

Determine the exact number of coins to place on each tree node using subtree cost products and DFS tracking.

Hard
3067

Count Pairs of Connectable Servers in a Weighted Tree Network

This problem involves counting pairs of connectable servers in a weighted tree network using binary-tree traversal and D…

Medium
3068

Find the Maximum Sum of Node Values

Solve Find the Maximum Sum of Node Values by tracking XOR gain parity, not by simulating edge operations across the tree…

Hard
3203

Find Minimum Diameter After Merging Two Trees

Calculate the minimum diameter after merging two trees by strategically connecting nodes to minimize the longest path in…

Hard
3241

Time Taken to Mark All Nodes

Calculate the time taken to mark all nodes in a tree, starting from any node with time t=0.

Hard
3249

Count the Number of Good Nodes

Determine how many nodes in a binary tree have all child subtrees of equal size using DFS traversal efficiently.

Medium
3319

K-th Largest Perfect Subtree Size in Binary Tree

Find the size of the kth largest perfect subtree in a binary tree using tree traversal and state tracking.

Medium
3327

Check if DFS Strings Are Palindromes

Determine if strings formed by DFS traversal of a tree are palindromes using array scanning and hash lookups efficiently…

Hard
3331

Find Subtree Sizes After Changes

Calculate the sizes of all subtrees after simultaneous parent changes using array scanning and hash-based counting effic…

Medium
3367

Maximize Sum of Weights after Edge Removals

Maximize the sum of edge weights in a tree after removals, using dynamic programming and tree traversal techniques.

Hard
3372

Maximize the Number of Target Nodes After Connecting Trees I

Maximize the number of target nodes after connecting two trees using binary tree traversal and state tracking.

Medium
3373

Maximize the Number of Target Nodes After Connecting Trees II

Maximize the number of target nodes after connecting two trees by analyzing their structure and target relationships.

Hard
3425

Longest Special Path

Compute the longest downward path in a tree with unique node values using DFS, hash lookup, and careful array scanning.

Hard
3486

Longest Special Path II

Find the longest downward path in a tree where node values are mostly distinct, allowing one repeat, using array scannin…

Hard
3515

Shortest Path in a Weighted Tree

Solve the Shortest Path in a Weighted Tree using binary-tree traversal and efficient state tracking for queries.

Hard
3544

Subtree Inversion Sum

This problem involves calculating the maximum possible subtree inversion sum with dynamic programming and binary-tree tr…

Hard
3553

Minimum Weighted Subgraph With the Required Paths II

Solve the Minimum Weighted Subgraph With the Required Paths II problem by leveraging binary-tree traversal and efficient…

Hard
3558

Number of Ways to Assign Edge Weights I

Calculate the number of valid edge weight assignments in a tree using DFS and binary-tree traversal with careful state t…

Medium
3559

Number of Ways to Assign Edge Weights II

This problem involves assigning edge weights in a tree and calculating the cost of paths based on these weights.

Hard
3562

Maximum Profit from Trading Stocks with Discounts

Solve the Maximum Profit from Trading Stocks with Discounts problem using binary-tree traversal and dynamic state tracki…

Hard
3575

Maximum Good Subtree Score

Find the maximum sum of values in a tree subtree without repeating any digit across selected nodes using DFS and bitmask…

Hard
3585

Find Weighted Median Node in Tree

Given a weighted tree and queries, find the weighted median node for each path between two nodes using binary-tree trave…

Hard
3590

Kth Smallest Path XOR Sum

This problem involves finding the kth smallest distinct XOR sum for nodes in a subtree of a tree structure using binary-…

Hard
3593

Minimum Increments to Equalize Leaf Paths

Find the minimum number of increments needed to equalize leaf path scores in a tree with different node costs.

Medium

Related Patterns

Tree LeetCode Problems: 191 Solutions