Tap here to switch tabs
Problem
Submissions

Problem: Find Minimum Cost to Remove Array Elements

med
30 min
Try to solve the Find Minimum Cost to Remove Array Elements problem.

Statement

You are given an integer array nums.

In each operation, you remove elements from nums based on the following rules:

  • If nums.length is at least 33, select any 22 elements from the first 33 elements of nums and remove them. The cost of this operation is the maximum of the 22 chosen elements.

  • If nums.length is less than 33, remove all remaining elements from nums. The cost of this operation is the maximum of all the removed elements.

Return the minimum total cost to remove all elements from nums.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 1≤1 \leq nums[i] ≤106\leq 10^6

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find Minimum Cost to Remove Array Elements

med
30 min
Try to solve the Find Minimum Cost to Remove Array Elements problem.

Statement

You are given an integer array nums.

In each operation, you remove elements from nums based on the following rules:

  • If nums.length is at least 33, select any 22 elements from the first 33 elements of nums and remove them. The cost of this operation is the maximum of the 22 chosen elements.

  • If nums.length is less than 33, remove all remaining elements from nums. The cost of this operation is the maximum of all the removed elements.

Return the minimum total cost to remove all elements from nums.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 1≤1 \leq nums[i] ≤106\leq 10^6