Skip to content

Practice Continuous Subarray Sum

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#523
LeetCode Problem

Continuous Subarray Sum

Problem Statement

Return whether nums has a contiguous subarray of at least two elements whose sum is a multiple of k. A sum of zero is a multiple of k and therefore qualifies when the length condition holds.

Source: Continuous Subarray Sum on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [23,2,4,6,7], k = 6
Output
true

# Example 2

Input
nums = [23,2,6,4,7], k = 6
Output
true

# Example 3

Input
nums = [23,2,6,4,7], k = 13
Output
false

Constraints

1 <= nums.length <= 10^5
0 <= nums[i] <= 10^9
0 <= sum(nums[i]) <= 2^31 - 1
1 <= k <= 2^31 - 1

Related LeetCode Problems

Practice more problems similar to Continuous Subarray Sum.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.