Make Sum Divisible by P SOLUTION

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
 

March Long Challenge 2021 Solutions

April Long Challenge 2021 Solutions

Codechef Long Challenge Solutions

February Long Challenge 2021

1. Frog Sort Solution Codechef

2. Chef and Meetings Solution Codechef

3. Maximise Function Solution Codechef

4. Highest Divisor Solution Codechef

5. Cut the Cake Challenge Solution Codechef

6. Dream and the Multiverse Solution Codechef

7. Cell Shell Solution Codechef

8. Multiple Games Solution Codechef

9. Another Tree with Number Theory Solution Codechef

10. XOR Sums Solution Codechef

11. Prime Game Solution CodeChef

12. Team Name Solution Codechef

January Long Challenge 2021

November Challenge 2020 SOLUTION CodeChef

October Lunchtime 2020 CodeChef SOLUTIONS

RELATED :

Related :

Related :

Leave a Comment

close
error: Content is protected !!
Free Udemy Courses and Hacking Resources Join Us on TelegramClick Here
+