All Posts

Leetcode 2684: Maximum Number of Moves in a Grid

You are given a matrix grid of size m x n filled with positive integers. Starting from any cell in the first column, you can move to any of the cells on the next column (right) that are strictly greater than the value of the current cell. The possible directions you can move to are: the cell directly to the right, the cell diagonally to the top-right, or the cell diagonally to the bottom-right. Your task is to return the maximum number of moves that you can perform by starting at any cell in the first column.

Leetcode 2707: Extra Characters in a String

You are given a string and a list of words. Your task is to break the string into one or more non-overlapping substrings such that each substring is a word from the given list. However, some characters of the string may not be used in any substring. Your goal is to minimize the number of unused characters.

Leetcode 2708: Maximum Strength of a Group

You are given an integer array representing the scores of students in an exam. Your task is to form a non-empty group of students such that the group’s strength, defined as the product of their scores, is maximized. The goal is to return the maximum possible strength that can be achieved by choosing an optimal group of students.

Leetcode 2712: Minimum Cost to Make All Characters Equal

You are given a binary string s of length n. You can perform two types of operations: (1) Flip all characters from index 0 to i (inclusive), with a cost of i + 1. (2) Flip all characters from index i to n - 1 (inclusive), with a cost of n - i. The goal is to return the minimum cost required to make all the characters in the string equal (either all 0s or all 1s).

Leetcode 2741: Special Permutations

You are given a list of distinct positive integers nums. A permutation of nums is considered special if, for every pair of consecutive numbers in the permutation, one number is divisible by the other. Your task is to return the total number of special permutations of nums, modulo 10^9 + 7.

Leetcode 2746: Decremental String Concatenation

You are given an array of distinct strings. Your task is to perform n-1 join operations optimally to minimize the length of the final string.