All Posts

Leetcode 2829: Determine the Minimum Sum of a k-avoiding Array

Given two integers, n and k, construct a k-avoiding array of length n. A k-avoiding array is an array of distinct positive integers where no two elements sum up to k. Return the minimum possible sum of such an array.

Leetcode 2844: Minimum Operations to Make a Special Number

You are given a non-negative integer represented as a string num. In one operation, you can remove any single digit from the string. If you remove all digits, the result becomes 0. Your task is to return the minimum number of operations required to make the number divisible by 25. A number is divisible by 25 if it ends in 00, 25, 50, or 75.

Leetcode 2856: Minimum Array Length After Pair Removals

You are given a non-decreasing sorted integer array. Perform operations to remove pairs of elements where nums[i] < nums[j] and return the minimum length of the array after the operations.

Leetcode 2864: Maximum Odd Binary Number

You are given a binary string s containing at least one ‘1’. Your task is to rearrange the bits in such a way that the resulting binary number is the largest possible odd binary number that can be formed from the given bits. A binary number is odd if its least significant bit (last bit) is ‘1’. The resulting binary number may contain leading zeros.

Leetcode 2870: Minimum Number of Operations to Make Array Empty

You are given an array nums consisting of positive integers. You are allowed to perform two types of operations on the array any number of times: (1) Choose two elements that are the same and remove them from the array. (2) Choose three elements that are the same and remove them from the array. Your task is to return the minimum number of operations required to empty the array, or return -1 if it is not possible to empty the array using these operations.

Leetcode 2871: Split Array Into Maximum Number of Subarrays

You are given an array nums consisting of non-negative integers. Your task is to divide the array into subarrays such that the sum of the scores of the subarrays is minimized. The score of a subarray nums[l..r] is defined as nums[l] AND nums[l + 1] AND … AND nums[r], where AND is the bitwise AND operation. Your goal is to return the maximum number of subarrays that you can split the array into while achieving the minimum possible sum of scores.