All Posts

Leetcode 2352: Equal Row and Column Pairs

Given a square matrix of integers, find the number of pairs of row and column indices where the row and column are equal in terms of their elements and their order.

Leetcode 2357: Make Array Zero by Subtracting Equal Amounts

You are given a non-negative integer array nums. In each operation, you must:

  • Choose a positive integer x that is less than or equal to the smallest non-zero element in nums.
  • Subtract x from every positive element in nums.

Return the minimum number of operations to make every element in nums equal to 0.

Leetcode 2358: Maximum Number of Groups Entering a Competition

You are given a positive integer array grades which represents the grades of students. Your goal is to group these students into ordered non-empty groups where:

  1. The sum of the grades in the i-th group is less than the sum of the grades in the (i + 1)-th group.
  2. The number of students in the i-th group is less than the number of students in the (i + 1)-th group. Return the maximum number of groups that can be formed.

Leetcode 2363: Merge Similar Items

You are given two 2D integer arrays, items1 and items2, each representing a set of items. Each item has a value and a weight. You need to combine both arrays by summing the weights of items with the same value, and return the result as a 2D array, sorted by the item values in ascending order.

Leetcode 2364: Count Number of Bad Pairs

You are given a 0-indexed integer array, nums. A pair of indices (i, j) is considered a ‘bad pair’ if i < j and j - i is not equal to nums[j] - nums[i]. Your task is to determine the total number of bad pairs in the array.

Leetcode 2365: Task Scheduler II

You are given an array of integers, tasks, representing tasks that need to be completed in order. Each element in tasks[i] represents the type of the i-th task. Additionally, a positive integer space is provided, representing the minimum number of days that must pass after completing a task before another task of the same type can be performed. Each day, you either complete the next task or take a break. Your goal is to determine the minimum number of days needed to complete all tasks.