All Posts

Leetcode 2522: Partition String Into Substrings With Values at Most K

Given a string s consisting of digits between 1 and 9, and an integer k, you need to partition the string into the fewest possible substrings such that the value of each substring is less than or equal to k. Each substring must consist of contiguous digits and must be interpreted as an integer. If it’s not possible to partition the string in such a way, return -1.

Leetcode 2530: Maximal Score After Applying K Operations

You are given a list of integers nums and an integer k. In each operation, you choose an index i, increase your score by nums[i], and replace nums[i] with ceil(nums[i] / 3). Apply exactly k operations and return the maximum score you can achieve.

Leetcode 2541: Minimum Operations to Make Array Equal II

You are given two integer arrays nums1 and nums2 of equal length n and an integer k. You can perform the following operation on nums1: Choose two indexes i and j and increment nums1[i] by k and decrement nums1[j] by k. The goal is to determine the minimum number of operations required to make nums1 equal to nums2. If it is impossible, return -1.

Leetcode 2542: Maximum Subsequence Score

You are given two integer arrays nums1 and nums2, both of size n, and a positive integer k. Your task is to select k indices from the array nums1, where the sum of the selected elements from nums1 is multiplied by the minimum element from the corresponding selected indices in nums2. The objective is to maximize this score.

Leetcode 2554: Maximum Number of Integers to Choose From a Range I

You are given an array banned consisting of integers, an integer n, and an integer maxSum. Your task is to return the maximum number of integers you can select from the range [1, n] such that none of them are in the banned list and their sum does not exceed maxSum.

Leetcode 2566: Maximum Difference by Remapping a Digit

You are given an integer num, and you know that Bob will sneakily remap one of the 10 possible digits (0 to 9) to another digit. Your task is to return the difference between the maximum and minimum values Bob can make by remapping exactly one digit in num. If no change is made, the value of num remains the same.