All Posts

Leetcode 1769: Minimum Number of Operations to Move All Balls to Each Box

You are given a binary string boxes of length n, where each character represents whether a box is empty (‘0’) or contains a ball (‘1’). Your task is to calculate, for each box, the minimum number of operations required to move all the balls to that particular box. An operation involves moving a ball from one box to an adjacent box.

Leetcode 1829: Maximum XOR for Each Query

You are given a sorted array nums of non-negative integers and an integer maximumBit. For each query, you need to find the optimal integer k (less than 2^maximumBit) such that the XOR of all elements in the current nums array and k is maximized. Remove the last element from nums after each query and return an array of results.

Leetcode 1838: Frequency of the Most Frequent Element

You are given an integer array nums and an integer k. In one operation, you can increment any element of the array by 1. Your task is to return the maximum possible frequency of any element after performing at most k operations.

Leetcode 1854: Maximum Population Year

You are given a 2D array logs where each entry represents the birth and death years of a person. You need to determine the earliest year that has the maximum population, where population is defined as the number of people alive in a given year.

Leetcode 1871: Jump Game VII

You are given a binary string s and two integers minJump and maxJump. Initially, you are at index 0 of the string s, which is guaranteed to be ‘0’. You can move from index i to index j if: i + minJump <= j <= min(i + maxJump, s.length - 1), and s[j] == ‘0’. Return true if it’s possible to reach the last index of the string (s.length - 1), or false otherwise.

Leetcode 1878: Get Biggest Three Rhombus Sums in a Grid

You are given an m x n matrix grid. A rhombus sum refers to the sum of the elements that form the border of a rhombus shape. The rhombus should be viewed as a square rotated 45 degrees, with each of its corners centered on a grid cell. Compute the biggest three distinct rhombus sums in the grid and return them in descending order. If there are fewer than three distinct sums, return all of them.