All Posts

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 3137: Minimum Number of Operations to Make Word K-Periodic

You are given a string word of length n, and an integer k such that k divides n. In one operation, you can pick any two indices i and j, both divisible by k, and swap the substrings starting from i and j, each of length k. The goal is to transform word into a k-periodic string, meaning that the string can be represented as multiple concatenations of a substring of length k. Your task is to determine the minimum number of operations required to make the string k-periodic.

Leetcode 3138: Minimum Length of Anagram Concatenation

You are given a string s, which is a concatenation of several anagrams of some string t. Your task is to find the minimum possible length of the string t. An anagram is formed by rearranging the letters of a string. For example, ‘abc’ and ‘cab’ are anagrams of each other. The string t is the original string that has been rearranged multiple times to form s.