Tap here to switch tabs
Problem
Submissions

Problem: Minimum Sum After Divisible Sum Deletions

Try to solve the Minimum Sum After Divisible Sum Deletions problem.

Statement

You are given an integer array nums and an integer k.

In one operation, you can select any contiguous subarray of nums whose sum of elements is divisible by k and remove it from the array. When a subarray is removed, the remaining elements on both sides merge together to form the updated array.

Return the minimum possible sum of the remaining elements in nums after performing this operation any number of times.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

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

  • 1≤1 \leq k ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Sum After Divisible Sum Deletions

Try to solve the Minimum Sum After Divisible Sum Deletions problem.

Statement

You are given an integer array nums and an integer k.

In one operation, you can select any contiguous subarray of nums whose sum of elements is divisible by k and remove it from the array. When a subarray is removed, the remaining elements on both sides merge together to form the updated array.

Return the minimum possible sum of the remaining elements in nums after performing this operation any number of times.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

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

  • 1≤1 \leq k ≤105\leq 10^5