Medium · Prefix Sum

Continuous Subarray Sum

Given an integer array nums and an integer k ≥ 1, return true if some contiguous subarray of length at least 2 has a sum that is a multiple of k (0 counts as a multiple), and false otherwise.

Examples

Example 1

[23,2,4,6,7], k=6

Output: true

Example 2

[23,2,6,4,7], k=13

Output: false

Rebuild it in the studio

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Prefix Sum problems