All Posts

Leetcode 1930: Unique Length-3 Palindromic Subsequences

You are given a string s, and you need to return the number of unique palindromic subsequences of length 3 that are subsequences of s.

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.

Leetcode 1947: Maximum Compatibility Score Sum

You are given a survey with n questions where each question’s answer is either 0 (no) or 1 (yes). The survey is completed by m students and m mentors. Each student’s answers are represented by a 2D array of size m x n, and similarly, each mentor’s answers are represented by another 2D array. The compatibility score of a student-mentor pair is calculated as the number of answers that are the same for both the student and the mentor. Your task is to find the optimal pairing of students to mentors that maximizes the sum of the compatibility scores.