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 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.

Leetcode 2380: Time Needed to Rearrange a Binary String

You are given a binary string s. In one second, all occurrences of the substring ‘01’ are simultaneously replaced with ‘10’. This process repeats until no occurrences of ‘01’ exist in the string. The task is to return the number of seconds required to complete this process.

Leetcode 2390: Removing Stars From a String

You are given a string s that contains lowercase English letters and stars (*). In each operation, you can choose a star in s, remove the closest non-star character to its left, and remove the star itself. Perform this operation until all stars are removed and return the resulting string.

Leetcode 2460: Apply Operations to an Array

You are given an array of non-negative integers. You need to perform a series of operations on this array where, in each operation, you compare adjacent elements. If the elements are equal, you double the value of the first element and set the second element to zero. After performing these operations on all pairs, shift all the zeros to the end of the array. Return the resulting array.