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:
- Initially, the permutation
P
is[1, 2, 3, ..., m]
. - For each
queries[i]
, find the index ofqueries[i]
in the permutationP
. - After locating
queries[i]
inP
, move it to the beginning of the list. - Return the list of indices (positions) for each element in
queries
as they are processed.