All Posts

Leetcode 2182: Construct String With Repeat Limit

Given a string of lowercase letters and an integer limit, construct a new string such that no character appears more than the given limit times consecutively. The new string should be lexicographically largest while satisfying this condition. You can use any subset of characters from the given string.

Leetcode 2185: Counting Words With a Given Prefix

You are given an array of strings and a target prefix. Your task is to count how many strings in the array start with this target prefix.

Leetcode 2186: Minimum Number of Steps to Make Two Strings Anagram II

You are given two strings, s and t. In each step, you can append any character to either s or t. Your task is to determine the minimum number of steps required to make s and t anagrams of each other.

Leetcode 2194: Cells in a Range on an Excel Sheet

You are given a range of cells in an Excel sheet, represented by two cell positions in the format ‘:’, where <col1> and <col2> represent the starting and ending column letters, and <row1> and <row2> represent the starting and ending row numbers. Your task is to return all the cells within the specified range, sorted first by column and then by row.

Leetcode 2207: Maximize Number of Subsequences in a String

You are given a string text and another string pattern of length 2, consisting of lowercase English letters. Your task is to insert one of the characters from pattern into text exactly once, and then return the maximum number of times pattern appears as a subsequence in the modified text.

Leetcode 2211: Count Collisions on a Road

You have n cars on a straight road, each numbered from 0 to n-1 from left to right, with each car positioned at a unique location. You are given a string directions where each character represents the direction of a car (‘L’ for left, ‘R’ for right, and ‘S’ for stationary). Each moving car has the same speed, and the cars can collide under the following conditions: Two cars moving in opposite directions (‘L’ and ‘R’) will collide, counting as 2 collisions. A moving car colliding with a stationary car (‘S’) will result in 1 collision. After a collision, the cars involved stay at the collision point and no longer move. Your task is to calculate the total number of collisions that will happen.