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 3162: Find the Number of Good Pairs I

You are given two integer arrays nums1 and nums2 of lengths n and m respectively, and a positive integer k. A pair (i, j) is called good if nums1[i] is divisible by nums2[j] * k (0 <= i <= n - 1, 0 <= j <= m - 1). Your task is to return the total number of good pairs.

Leetcode 3169: Count Days Without Meetings

You are given a positive integer days representing the total number of days an employee is available for work (starting from day 1). Additionally, you are given a 2D array meetings, where meetings[i] = [start_i, end_i] represents the start and end days (inclusive) of the ith meeting. Your task is to determine the number of days when the employee is available for work, but no meetings are scheduled.

Leetcode 3179: Find the N-th Value After K Seconds

You are given two integers, n and k. Initially, you have an array a of size n, where each element is initialized to 1. After each second, every element in the array is updated to be the sum of all preceding elements plus the element itself. The process repeats for k seconds. You need to return the value of the last element of the array, a[n - 1], after k seconds. Since the result may be very large, return it modulo (10^9 + 7).

Leetcode 3190: Find Minimum Operations to Make All Elements Divisible by Three

You are given an array of integers nums. In each operation, you can either add or subtract 1 from any element in nums. Your task is to determine the minimum number of operations required to make all elements of nums divisible by 3.