All Posts
Leetcode 851: Loud and Rich
n
people, each with a unique amount of money and quietness. An array richer
specifies the relationships between people where richer[i] = [ai, bi]
indicates that person ai
has more money than person bi
. You are also given an array quiet
where quiet[i]
represents the quietness of person i
. Your task is to return an array answer
where answer[x]
is the person y
who has the least quietness among all people who have equal or more money than person x
.
You are given a group of Leetcode 852: Peak Index in a Mountain Array
arr
of length n
, where the values first strictly increase to a peak element and then strictly decrease. Your task is to find the index of the peak element in the array. The peak element is an element that is greater than both its neighbors.
You are given a mountain array Leetcode 853: Car Fleet
You are given several cars starting at different positions along a road. Each car has a specific speed and is trying to reach a target destination. A car cannot pass another car, but it can catch up and travel at the speed of the slower car. Cars that travel together form a fleet. Your task is to determine the number of car fleets that will reach the target.
Leetcode 855: Exam Room
You are tasked with simulating an exam room where students will choose seats based on a strategy that maximizes their distance from the closest person already seated. If multiple seats have the same distance, the student will choose the seat with the smallest index. Additionally, students can leave the room, freeing up their seats.
Leetcode 856: Score of Parentheses
Given a balanced parentheses string, calculate the score of the string. The score is computed as follows:
- The score of ‘()’ is 1.
- For a concatenation of two balanced parentheses strings, AB, the score is the sum of their individual scores (A + B).
- For a balanced parentheses string wrapped in another pair of parentheses, (A), the score is twice the score of A (2 * A).