All Posts

Leetcode 103: Binary Tree Zigzag Level Order Traversal

Given the root of a binary tree, your task is to return the zigzag level order traversal of its nodes’ values. This means you need to traverse the tree level by level, alternating between left to right and right to left on each level.

Leetcode 104: Maximum Depth of Binary Tree

You are given the root of a binary tree. Your task is to return the maximum depth of the tree. The maximum depth is defined as the number of nodes along the longest path from the root node down to the farthest leaf node.

Leetcode 105: Construct Binary Tree from Preorder and Inorder Traversal

Given two integer arrays, preorder and inorder, representing the preorder and inorder traversals of a binary tree, your task is to reconstruct and return the binary tree. The values in the arrays are unique, and the preorder traversal provides the sequence in which nodes are visited before their children, while the inorder traversal provides the order in which nodes are visited between their children.

Leetcode 107: Binary Tree Level Order Traversal II

Given the root of a binary tree, return the bottom-up level order traversal of its nodes’ values. This means that for each level, starting from the leaf level and moving towards the root, you should collect the node values from left to right.

Leetcode 109: Convert Sorted List to Binary Search Tree

Given the head of a singly linked list where elements are sorted in ascending order, convert it into a height-balanced binary search tree. A height-balanced binary search tree is one where the depth of the two subtrees of every node never differs by more than 1.

Leetcode 110: Balanced Binary Tree

Given a binary tree, determine if it is height-balanced. A binary tree is considered height-balanced if for every node, the height of the left and right subtrees differs by no more than one.