Tap here to switch tabs
Problem
Submissions

Problem: Minimum Sum After Divisible Sum Deletions

Minimum Sum After Divisible Sum Deletions gives a positive integer array and k. Repeatedly remove contiguous subarrays with sums divisible by k, then return the smallest possible sum left.

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

Minimum Sum After Divisible Sum Deletions gives a positive integer array and k. Repeatedly remove contiguous subarrays with sums divisible by k, then return the smallest possible sum left.

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