Practice Make Sum Divisible by P
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Given an array of positive integers nums, remove the smallest subarray (possibly empty) such that the sum of the remaining elements is divisible by p. It is not allowed to remove the whole array. Return the length of the smallest subarray that you need to remove, or -1 if it's impossible. A subarray is defined as a contiguous block of elements in the array.
Source: Make Sum Divisible by P on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums = [3,1,4,2], p = 6
1
# Example 2
nums = [6,3,5,2], p = 9
2
# Example 3
nums = [1,2,3], p = 3
0
Constraints
Related LeetCode Problems
Practice more problems similar to Make Sum Divisible by P.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.