All Posts

Leetcode 851: Loud and Rich

You are given a group of 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.

Leetcode 852: Peak Index in a Mountain Array

You are given 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.

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:

  1. The score of ‘()’ is 1.
  2. For a concatenation of two balanced parentheses strings, AB, the score is the sum of their individual scores (A + B).
  3. For a balanced parentheses string wrapped in another pair of parentheses, (A), the score is twice the score of A (2 * A).

Leetcode 858: Mirror Reflection

In a special square room with mirrors on all four walls, except for the southwest corner, there are receptors at three other corners, numbered 0, 1, and 2. A laser ray is fired from the southwest corner and hits the east wall at a certain distance from the 0th receptor. Given the side length of the square room, p, and the distance q from the 0th receptor on the east wall where the laser ray meets, return the number of the receptor the ray hits first after bouncing around the room.