All Posts

Leetcode 1376: Time Needed to Inform All Employees

A company has n employees with a unique ID for each employee from 0 to n-1. The head of the company is the one with headID. Each employee has one direct manager. The head will inform his direct subordinates, and they will inform their subordinates, and so on until all employees know about the urgent news. Each employee needs informTime[i] minutes to inform their direct subordinates. Return the total time required to inform all employees.

Leetcode 1379: Find a Corresponding Node of a Binary Tree in a Clone of That Tree

You are given two binary trees: an original tree and a cloned tree. The cloned tree is a copy of the original tree, and you are given a reference to a node in the original tree. Your task is to return the reference to the corresponding node in the cloned tree.

Leetcode 1382: Balance a Binary Search Tree

Given the root of a binary search tree (BST), return a balanced BST containing the same node values. A balanced BST is one where the depth of the left and right subtrees of every node never differ by more than 1.

Leetcode 1443: Minimum Time to Collect All Apples in a Tree

You are given an undirected tree with n vertices numbered from 0 to n-1. Some vertices in this tree contain apples. Each edge in the tree requires 1 second to traverse. Starting at vertex 0, determine the minimum time required to collect all apples and return to vertex 0. The tree structure is described by the array edges, where edges[i] = [ai, bi] indicates an edge between vertices ai and bi. Additionally, the array hasApple specifies whether a vertex contains an apple (true) or not (false).

Leetcode 1448: Count Good Nodes in Binary Tree

Given the root of a binary tree, a node is considered ‘good’ if in the path from the root to that node, there are no nodes with a value greater than the node itself. Return the total number of good nodes in the tree.

Leetcode 1457: Pseudo-Palindromic Paths in a Binary Tree

You are given a binary tree where each node contains a digit from 1 to 9. A path from the root to a leaf node is considered pseudo-palindromic if at least one permutation of the node values in the path can form a palindrome. Your task is to return the number of pseudo-palindromic paths in the tree.