All Posts

Leetcode 652: Find Duplicate Subtrees

Given the root of a binary tree, return all duplicate subtrees. For each duplicate subtree, return the root node of any one of them. Two trees are considered duplicates if they have the same structure and node values.

Leetcode 655: Print Binary Tree

Given the root of a binary tree, construct a matrix representation of the tree using specific formatting rules to place each node in the appropriate position in the matrix.

Leetcode 662: Maximum Width of Binary Tree

You are given the root of a binary tree. Determine the maximum width of the tree, which is defined as the maximum width among all levels. The width of a level is the distance between the leftmost and rightmost non-null nodes, including null nodes in between that would be present in a complete binary tree.

Leetcode 669: Trim a Binary Search Tree

You are given the root of a binary search tree (BST) and two integer values low and high. Trim the tree such that all its elements lie within the inclusive range [low, high]. The tree’s relative structure should remain unchanged, and the root may change depending on the given bounds.

Leetcode 672: Bulb Switcher II

You are in a room with n bulbs, all initially turned on. There are four buttons on the wall, each with a different functionality: flip all bulbs, flip even-numbered bulbs, flip odd-numbered bulbs, and flip bulbs with labels j = 3k + 1. You need to make exactly presses presses. For each press, you can choose any button. Return the number of distinct possible configurations of the bulbs after performing all the presses.

Leetcode 676: Implement Magic Dictionary

Design a data structure that supports searching for words that can be matched by changing exactly one character.