All Posts

Leetcode 2536: Increment Submatrices by One

You are given a positive integer n representing the size of an n x n matrix initially filled with zeros, and a 2D integer array queries. Each query consists of four integers [row1, col1, row2, col2]. For each query, add 1 to every element in the submatrix from (row1, col1) to (row2, col2) in the matrix. Return the matrix after applying all queries.

Leetcode 2537: Count the Number of Good Subarrays

Given an integer array nums and an integer k, return the number of “good” subarrays. A subarray is good if it contains at least k pairs of indices (i, j) such that i < j and nums[i] == nums[j]. A subarray is a contiguous non-empty sequence of elements within the array.

Leetcode 2540: Minimum Common Value

Given two integer arrays nums1 and nums2 sorted in non-decreasing order, return the smallest integer that is common to both arrays. If no such integer exists, return -1.

Leetcode 2541: Minimum Operations to Make Array Equal II

You are given two integer arrays nums1 and nums2 of equal length n and an integer k. You can perform the following operation on nums1: Choose two indexes i and j and increment nums1[i] by k and decrement nums1[j] by k. The goal is to determine the minimum number of operations required to make nums1 equal to nums2. If it is impossible, return -1.

Leetcode 2542: Maximum Subsequence Score

You are given two integer arrays nums1 and nums2, both of size n, and a positive integer k. Your task is to select k indices from the array nums1, where the sum of the selected elements from nums1 is multiplied by the minimum element from the corresponding selected indices in nums2. The objective is to maximize this score.

Leetcode 2545: Sort the Students by Their Kth Score

You are given a matrix of scores, where each row represents a student and each column represents an exam. You need to sort the students based on their scores in the k-th exam, from the highest to the lowest. Return the sorted matrix.