All Posts

Leetcode 2615: Sum of Distances

You are given a 0-indexed integer array nums. For each element nums[i], compute the sum of absolute differences |i - j| for all indices j where nums[j] == nums[i] and j != i. If there are no such indices, set the corresponding value in the result array to 0. Return the resulting array.

Leetcode 2616: Minimize the Maximum Difference of Pairs

You are given a 0-indexed integer array nums and an integer p. Your task is to find p pairs of indices such that the maximum absolute difference between any of the pairs is minimized. Each index can be used in at most one pair. Return the minimized value of the maximum difference among all the pairs.

Leetcode 2639: Find the Width of Columns of a Grid

You are given a 0-indexed m x n integer matrix grid. The width of a column is determined by the length of its longest integer. For example, the length of an integer is defined as the number of digits in its absolute value, with an additional digit for negative numbers. For each column, return its width, which is the maximum length of any integer in that column.

Leetcode 2640: Find the Score of All Prefixes of an Array

You are given a 0-indexed integer array nums of length n. For each prefix nums[0..i], you are asked to calculate its ‘score.’ The score is defined as the sum of the conversion array of the prefix. The conversion array of a prefix is formed by the following rule: conver[i] = nums[i] + max(nums[0..i]), where max(nums[0..i]) is the maximum value in the prefix from the start to the current index.

Leetcode 2643: Row With Maximum Ones

Given a binary matrix of size m x n, your task is to find the row that contains the highest number of 1’s. If there are multiple rows with the same count of 1’s, return the row with the smallest index. The output should contain the index of the row and the count of 1’s in that row.

Leetcode 2644: Find the Maximum Divisibility Score

You are given two integer arrays, ’nums’ and ‘divisors’. For each element in ‘divisors’, you need to calculate the divisibility score, which is the number of elements in ’nums’ divisible by that divisor. Your goal is to return the divisor with the highest divisibility score. If multiple divisors have the same score, return the smallest one.