All Posts
Leetcode 3101: Count Alternating Subarrays
You are given a binary array nums. A subarray is called alternating if no two adjacent elements in the subarray have the same value. Return the total number of alternating subarrays in the given binary array.
Leetcode 3121: Count the Number of Special Characters II
word
. A letter c
is called special if it appears both in lowercase and uppercase in word
, and every lowercase occurrence of c
appears before the first uppercase occurrence of c
. Return the number of special letters in word
.
You are given a string 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 3128: Right Triangles
You are given a 2D binary matrix grid, where each element is either 0 or 1. A collection of three elements of the grid is considered a right triangle if one element lies in the same row as another and in the same column as the third. The three elements must not be adjacent to each other. Your task is to count the number of right triangles that can be formed where all three elements have a value of 1.
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.