All Posts

Leetcode 1926: Nearest Exit from Entrance in Maze

You are given a maze and need to find the nearest exit from the entrance. An exit is defined as an empty cell on the border of the maze. Return the shortest path to the nearest exit, or -1 if no exit is reachable.

Leetcode 1929: Concatenation of Array

You are given an integer array nums and are required to return a new array where nums is repeated twice in a row.

Leetcode 1936: Add Minimum Number of Rungs

You are at the bottom of a ladder with several rungs already placed. The distance between consecutive rungs should not exceed a given value ‘dist’. If the gap between any two rungs exceeds ‘dist’, you can insert additional rungs to make the ladder climbable. Return the minimum number of rungs that need to be added.

Leetcode 1937: Maximum Number of Points with Cost

You are given a matrix of integers points with dimensions m x n (0-indexed). Initially, you are at score 0, and your goal is to maximize the score by selecting one cell in each row. To gain points, you can select a cell (r, c) from each row. The value at points[r][c] will add to your score. However, if you choose cells from different columns in adjacent rows, the difference between their column indices will subtract from your score. Specifically, if you select a cell at (r, c1) in row r and a cell at (r + 1, c2) in row r + 1, the penalty is abs(c1 - c2). Your task is to return the maximum score you can achieve by choosing cells from each row.

Leetcode 1942: The Number of the Smallest Unoccupied Chair

In a party, there are n friends with distinct arrival and departure times. Each friend chooses the smallest available chair. The task is to determine the chair number where the friend numbered targetFriend will sit.

Leetcode 1943: Describe the Painting

You are given a painting represented by a number line. Multiple overlapping segments are painted with different colors. Your task is to return a minimal set of non-overlapping painted segments, where each segment represents a portion of the painting with a unique set of mixed colors. Each segment should be represented by the sum of the colors in the mixed sets.