All Posts
Leetcode 2919: Minimum Increment Operations to Make Array Beautiful
nums
of length n
and an integer k
. You can perform an operation where you pick an index i
in the range [0, n - 1]
and increment nums[i]
by 1. You can perform this operation any number of times (including zero). A subarray is considered beautiful if, for every subarray of size 3 or more, the maximum element in that subarray is greater than or equal to k
. Your task is to return the minimum number of increment operations needed to make the array beautiful.
You are given a 0-indexed integer array Leetcode 2944: Minimum Number of Coins for Fruits
You are given a list of integers ‘prices’, where each element ‘prices[i]’ represents the cost to purchase the ‘i’-th fruit. If you buy the ‘i’-th fruit at prices[i] coins, you get all subsequent fruits for free. Your task is to determine the minimum number of coins required to purchase all the fruits.
Leetcode 2957: Remove Adjacent Almost-Equal Characters
You are given a 0-indexed string word. In each operation, you can change any character of word to a lowercase English letter. Two characters are considered almost-equal if they are the same or adjacent in the alphabet. Your task is to remove all adjacent almost-equal characters with the minimum number of operations.
Leetcode 3122: Minimum Number of Operations to Satisfy Conditions
grid
of size m x n
. In one operation, you can change the value of any cell to any non-negative number. Your task is to perform operations such that each cell is equal to the cell below it, and different from the cell to its right. Return the minimum number of operations needed to achieve these conditions.
You are given a 2D matrix Leetcode 3129: Find All Possible Stable Binary Arrays I
You are given three positive integers: zero
, one
, and limit
. A binary array is called stable if it satisfies the following conditions:
- It contains exactly one occurrence of the number 1.
- It contains exactly zero occurrences of the number 0.
- Any subarray of size greater than
limit
must contain both 0 and 1.
Return the total number of stable binary arrays that can be formed. Since the answer can be large, return it modulo 10^9 + 7.