All Posts

Leetcode 2567: Minimum Score by Changing Two Elements

You are given an integer array nums. Your goal is to minimize the score of the array after changing exactly two elements. The score is the sum of the low and high scores, where the low score is the minimum absolute difference between any two integers and the high score is the maximum absolute difference between any two integers.

Leetcode 2571: Minimum Operations to Reduce an Integer to 0

You are given a positive integer n. You can perform the following operation any number of times: Add or subtract a power of 2 from n. Your goal is to find the minimum number of operations required to make n equal to 0.

Leetcode 2576: Find the Maximum Number of Marked Indices

You are given a 0-indexed integer array nums. Initially, all indices are unmarked. You are allowed to perform the following operation any number of times: Pick two different unmarked indices i and j such that 2 * nums[i] <= nums[j], then mark both indices i and j. Return the maximum possible number of marked indices after performing this operation multiple times.

Leetcode 2578: Split With Minimum Sum

Given a positive integer num, split it into two non-negative integers num1 and num2 such that the concatenation of num1 and num2 is a permutation of the digits of num. The goal is to minimize the sum of num1 and num2.

Leetcode 2587: Rearrange Array to Maximize Prefix Score

You are given a 0-indexed integer array nums. In one operation, you can choose two indices and subtract a power of two from both elements at those indices. A subarray is considered beautiful if you can make all of its elements equal to zero by applying the operation any number of times. Your task is to return the number of beautiful subarrays in nums.

Leetcode 2591: Distribute Money to Maximum Children

You are given an integer money and an integer children. You need to distribute the money to the children such that everyone gets at least 1 dollar, nobody gets exactly 4 dollars, and you maximize the number of children receiving exactly 8 dollars. Return the maximum number of children who receive 8 dollars, or -1 if it’s not possible.