[Leetcode]1590. Make Sum Divisible by P

LeetCode_logo
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.
Continue reading “[Leetcode]1590. Make Sum Divisible by P”

[Leetcode]1497. Check If Array Pairs Are Divisible by k

LeetCode_logo
Given an array of integers arr of even length n and an integer k.
We want to divide the array into exactly n / 2 pairs such that the sum of each pair is divisible by k.
Return True If you can find a way to do that or False otherwise.
 
Example 1:
Input: arr = [1,2,3,4,5,10,6,7,8,9], k = 5 Output: true 
Explanation: Pairs are (1,9),(2,8),(3,7),(4,6) and (5,10).
Continue reading “[Leetcode]1497. Check If Array Pairs Are Divisible by k”