All Posts

Leetcode 1104: Path In Zigzag Labelled Binary Tree

You are given a label representing a node in an infinite binary tree. In this binary tree, each level alternates between left-to-right and right-to-left labeling. Your task is to return the path from the root of the tree to the node with the given label, following the zigzag pattern.

Leetcode 1110: Delete Nodes And Return Forest

Given the root of a binary tree, and a list of values to delete, your task is to remove the nodes with the given values. The resulting tree will become a forest, where each tree is a disjoint set of nodes. Return the roots of the trees in the remaining forest.

Leetcode 1123: Lowest Common Ancestor of Deepest Leaves

Given the root of a binary tree, your task is to return the lowest common ancestor (LCA) of its deepest leaf nodes. The LCA of a set of nodes is the deepest node that is an ancestor of all the nodes in the set. A leaf node is one that does not have any children.

Leetcode 1145: Binary Tree Coloring Game

Two players play a turn-based game on a binary tree. We are given the root of the tree and the number of nodes, n, where n is odd, and each node has a distinct value from 1 to n. Player 1 selects a value x and colors the corresponding node red, while Player 2 selects a value y (where yx) and colors the corresponding node blue. Players take turns coloring neighboring nodes. The game ends when both players pass their turns, and the winner is the player who colored more nodes. Your task is to determine if Player 2 can guarantee a win by choosing a value y.

Leetcode 1161: Maximum Level Sum of a Binary Tree

Given the root of a binary tree, find the smallest level x (1-indexed) such that the sum of the values of nodes at level x is maximal. Each level of the tree corresponds to the distance from the root, with the root being level 1.

Leetcode 1261: Find Elements in a Contaminated Binary Tree

Given a contaminated binary tree, recover it and implement a class to search for specific values in the tree.