All Posts
Leetcode 2033: Minimum Operations to Make a Uni-Value Grid
x
. In each operation, you can either add x
or subtract x
from any element in the grid. Your task is to transform the grid into a uni-value grid, where all elements are equal. Return the minimum number of operations needed to achieve this, or return -1 if it is not possible.
You are given a 2D grid of integers, and an integer Leetcode 2038: Remove Colored Pieces if Both Neighbors are the Same Color
colors
consisting of two types of pieces, ‘X’ and ‘Y’, arranged in a line. Two players, Alex and Brian, play a game where they take turns removing pieces from the string. Alex moves first and can only remove a piece ‘X’ if both its neighbors are also ‘X’. Similarly, Brian can only remove a piece ‘Y’ if both its neighbors are also ‘Y’. Neither player can remove edge pieces. If a player cannot make a move, they lose. Determine whether Alex wins the game if both players play optimally.
You are given a string Leetcode 2048: Next Greater Numerically Balanced Number
An integer x is numerically balanced if, for every digit d in x, the digit d occurs exactly d times in the number. For example, 22 is numerically balanced because the digit 2 appears exactly 2 times, while 3133 is numerically balanced because the digit 3 appears exactly 3 times, and the digit 1 appears exactly 1 time.
Given an integer n, find the smallest numerically balanced integer that is strictly greater than n.