All Posts

Leetcode 406: Queue Reconstruction by Height

You are given an array of people, where each person is represented by two integers: their height hi and the number of people ki in front of them who have a height greater than or equal to hi. Your task is to reconstruct the queue based on these attributes.

Leetcode 673: Number of Longest Increasing Subsequence

Given an integer array nums, return the number of distinct longest increasing subsequences.

Leetcode 1395: Count Number of Teams

You are given a list of soldiers, each with a unique rating. You need to form teams of 3 soldiers from this list. A valid team is one where the soldiers’ ratings are either strictly increasing or strictly decreasing as we move from left to right in the team. The team must satisfy the condition that the indices (i, j, k) follow 0 <= i < j < k < n.

Leetcode 1409: Queries on a Permutation With Key

You are given a list of positive integers called queries, each between 1 and m. You need to process each element in queries sequentially according to the following rules:

  1. Initially, the permutation P is [1, 2, 3, ..., m].
  2. For each queries[i], find the index of queries[i] in the permutation P.
  3. After locating queries[i] in P, move it to the beginning of the list.
  4. Return the list of indices (positions) for each element in queries as they are processed.

Leetcode 2250: Count Number of Rectangles Containing Each Point

You are given a 2D integer array rectangles, where each element rectangles[i] = [li, hi] represents a rectangle with a bottom-left corner at (0, 0), a length li, and a height hi. Additionally, you are provided a 2D integer array points, where each element points[j] = [xj, yj] represents a point on a 2D plane. The task is to determine the number of rectangles that contain each point. A rectangle contains a point if the point satisfies 0 <= xj <= li and 0 <= yj <= hi. Points on the edges of rectangles are also considered to be inside.

Leetcode 2424: Longest Uploaded Prefix

You are given a stream of n distinct videos, each represented by a unique number from 1 to n. You need to design a data structure that tracks the longest prefix of uploaded videos at any point in time. A prefix is considered uploaded if all videos from 1 to i (inclusive) have been uploaded to the server.