Continuous subarray sum and Cutting ribbons
Given an array of non-negative integers and an integer m, create a function that determines whether there exists a continuous subarray of length at least 2 whose sum is a multiple of m. In other words, the sum of that subarray should equal p * m where p is an integer.
Example 1: Array: [20, 3, 5, 7, 9], m = 7 Output: True Explanation: The subarray [5, 7] has a sum of 12, which is a multiple of 7 (7*1 = 7) — actually 12 is not a multiple of 7, so let's pick a better example: Let's change example 1 to: Array: [20, 3, 8, 7, 9], m = 8 Output: True Explanation: The subarray [8, 7] sums to 15 which is not a multiple of 8, so let's correct this example properly: Example 1: Array: [20, 4, 4, 7, 9], m = 8 Output: True Explanation: The subarray [4, 4] sums to 8, which is 1*8. Example 2: Array: [21, 2, 8, 5, 10], m = 5 Output: True Explanation: The entire array sums to 46, which is not a multiple of 5, but the subarray [5, 10] sums to 15, which is 3*5.