Skip to content

Practice Minimum Array Sum

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#3366
LeetCode Problem

Minimum Array Sum

Problem Statement

Given nums, k, op1, and op2, you may halve an entry and round up, at most op1 times overall and once per index. You may also subtract k from an entry whose current value is at least k, at most op2 times overall and once per index. Both operation types may affect the same index in either order, subject to those rules. Return the minimum possible array sum.

Source: Minimum Array Sum on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [2,8,3,19,3], k = 3, op1 = 1, op2 = 1
Output
23

# Example 2

Input
nums = [2,4,3], k = 3, op1 = 2, op2 = 1
Output
3

Constraints

1 <= nums.length <= 100
0 <= nums[i] <= 10^5
0 <= k <= 10^5
0 <= op1, op2 <= nums.length

Related LeetCode Problems

Practice more problems similar to Minimum Array Sum.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.