# Make Sum Divisible by P SOLUTION

Page Contents

### Make Sum Divisible by P SOLUTION Biweekly Contest 35

Given a variety of positive whole numbers nums, eliminate the littlest subarray (perhaps unfilled) with the end goal that the aggregate of the rest of the components is distinct by p. It isn’t permitted to eliminate the entire exhibit.

Return the length of the littlest subarray that you have to eliminate, or – 1 if it’s unthinkable.

A subarray is characterized as an adjacent square of components in the exhibit.

Model 1:

Information: nums = [3,1,4,2], p = 6

Yield: 1

Clarification: The total of the components in nums is 10, which isn’t distinguishable by 6. We can eliminate the subarray [4], and the total of the rest of the components is 6, which is separable by 6.

Model 2:

Info: nums = [6,3,5,2], p = 9

Yield: 2

Clarification: We can’t eliminate a solitary component to get an aggregate distinguishable by 9. The most ideal path is to eliminate the subarray [5,2], leaving us with [6,3] with aggregate 9.

Model 3:

Info: nums = [1,2,3], p = 3

Yield: 0

Clarification: Here the aggregate is 6. which is as of now separable by 3. Subsequently we don’t have to eliminate anything.

Model 4:

Info: nums = [1,2,3], p = 7

Yield: – 1

Clarification: There is no real way to eliminate a subarray so as to get an aggregate detachable by 7.

Model 5:

Info: nums = [1000000000,1000000000,1000000000], p = 3

Yield: 0

Limitations:

1 <= nums.length <= 105

1 <= nums[i] <= 109

1 <= p <= 109