All Posts

Leetcode 1090: Largest Values From Labels

You are given two arrays, values and labels, representing the value and label of items, respectively. Your goal is to choose a subset of items with the maximum sum of values such that the number of items selected is at most numWanted and no label appears more than useLimit times in the subset. Return the maximum possible sum of the values from the selected subset of items.

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 1122: Relative Sort Array

You are given two arrays: arr1 and arr2. The elements of arr2 are distinct, and all elements in arr2 exist in arr1. The task is to sort the elements of arr1 such that the relative ordering of elements in arr1 matches the order of elements in arr2. Elements in arr1 that are not present in arr2 should be placed at the end of arr1 in ascending order.

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 1124: Longest Well-Performing Interval

You are given a list of integers representing the number of hours worked each day. A day is considered tiring if the number of hours worked is strictly greater than 8. A well-performing interval is an interval of days where the number of tiring days is strictly larger than the number of non-tiring days. Your task is to return the length of the longest well-performing interval.

Leetcode 1138: Alphabet Board Path

You are given an alphabet board. Starting at position (0, 0), you need to move around the board to form the target string using the minimum number of moves. The allowed moves are ‘U’, ‘D’, ‘L’, ‘R’, and ‘!’ to select the character at the current position.