1590. Make Sum Divisible by P
https://leetcode.com/problems/make-sum-divisible-by-p
Description
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.
Example 1:
Example 2:
Example 3:
Example 4:
Example 5:
Constraints:
1 <= nums.length <= 105
1 <= nums[i] <= 109
1 <= p <= 109
ac
Last updated