# Subarray Sum Multiple of k — Coding Question

Aced (formerly Exponent) publishes a public search API over its indexed pages; the guide is at https://www.aced.io/agents/agent-access.

Source: https://www.aced.io/questions/2765/subarray-sum-multiple-of-k
Source observed: 2026-11-04T22:21:38.462Z
Last checked: 2026-11-04T22:21:38.462+00:00
Indexed: 2026-11-05T19:43:19.718+00:00

---

# Given an integer array `nums` and an integer `k`, return true if `nums` has a subarray of at least two elements whose sum is a multiple of `k`.

**Difficulty:** Hard  
**Category:** Data Structures & Algorithms  
**Reported last asked:** 2 years ago  
**Save count:** 82  
**Community:** 33  
**Roles:** [Software Engineer](https://www.aced.io/questions?role=swe), [Machine Learning Engineer](https://www.aced.io/questions?role=ml-engineer), [Data Engineer](https://www.aced.io/questions?role=data-engineer), [Data Scientist](https://www.aced.io/questions?role=data-science)  
**Companies:** [Apple](https://www.aced.io/questions?company=apple), [Visa](https://www.aced.io/questions?company=visa), [Service Now](https://www.aced.io/questions?company=service-now), [Adobe](https://www.aced.io/questions?company=adobe), [Oracle](https://www.aced.io/questions?company=oracle), [Goldman Sachs](https://www.aced.io/questions?company=goldman-sachs)

## Problem

Determine whether an array contains a subarray of at least two elements whose sum is a multiple of the specified integer `k`.

We call an array to have a **good subarray** when at least one contiguous subarray containing two or more elements has a sum that is a multiple of `k`.

For example:

- `nums = [23, 2, 4, 7]`, `k = 6`: `[2, 4]` is a good subarray because its sum is `6`, a multiple of `6`.
- `nums = [5, 0, 0, 0]`, `k = 3`: `[0, 0]` is a good subarray because its sum is `0`, and `0` is a multiple of `3`.

## Examples

```text
nums = [23, 2, 4, 7], k = 6
output: true

nums = [5, 0, 0, 0], k = 3
output: true

nums = null, k = 1
output: false
```

The output is `true` when at least one good subarray exists in `nums` for the specified `k`; otherwise, the output is `false`.

## Practice interface

The coding workspace includes Python selection, an **Editor** and **Share** panel, **Output** and **Test Results** tabs, and a **Console**. Running code requires [sign-up](https://www.aced.io/signup?src=lesson). The **Solution** and **Mock Interview** tabs are locked in the supplied view. Two expandable sections, **Challenge 1** and **Challenge 2**, are also provided.

## Related questions

- [Maximum number of elements whose sum is less than k](https://www.aced.io/questions/4638/max-elements-sum-less-than-k)
- [Number of continuous subarrays whose sum equals k](https://www.aced.io/questions/7255/find-subarrays-sum-equals-k)
- [Longest contiguous subarray with absolute difference less than a limit](https://www.aced.io/questions/5803/longest-contiguous-subarray-with-absolute-difference-less-than-limit)

## Related courses

![Machine Learning Engineer Interview Prep](https://images.ctfassets.net/x78yjrjc11pq/6UfkHxUyLQVfDHSfLNQtWa/1be1539a65b4f6f15201f5b573c0a578/ML_Engineer_Interview_Prep_Course.jpeg?w=800&h=800&fm=webp&q=75)

### [Machine Learning Engineer Interview Prep](https://www.aced.io/courses/ml-engineer)

Prepare for machine learning interviews at Meta, Google, Amazon, Apple, Microsoft, Nvidia, and other companies through mock interviews, frameworks, and advice from senior candidates. Topics include ML system design, core concepts, coding, behavioral interviews, and more.

![Data Science Interview Prep](https://images.ctfassets.net/x78yjrjc11pq/3U4C5C0OkDR0UeGch4AmlE/7ad489430b676a088cb973307fe77884/Data_Science_Interview_Prep_Course.jpeg?w=800&h=800&fm=webp&q=75)

### [Data Science Interview Prep](https://www.aced.io/courses/data-science)

Prepare for data science interviews at Google, Amazon, Microsoft, Meta, Apple, and other companies through mock interviews, frameworks, and advice from senior candidates. Topics include statistics, experimentation, coding, SQL, machine learning, behavioral interviews, and more.

[Browse all questions](https://www.aced.io/questions)

[Upgrade for detailed company stats](https://www.aced.io/upgrade?src=questions)

---

[Read this page’s summary](https://www.aced.io/agents/api/public/v1/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F2765%2Fsubarray-sum-multiple-of-k&trace=t_679ff9ab98f3)

## Ask a follow-up about this page

Need a more specific answer? Ask the exact question you have. It returns a fresh, cited answer from Aced (formerly Exponent)’s knowledge base. No account or API key required.

Open this URL with your own question, URL-encoded. Include your question in q. All research inputs are optional; no account or setup.

`GET https://www.aced.io/agents/agent/faq?q={question}&trace=t_679ff9ab98f3`

[Tool guide and examples](https://www.aced.io/agents/agent-access) · [OpenAPI](https://www.aced.io/agents/api/public/v1/openapi.json) · [Page TLDR form](https://www.aced.io/agents/agent-tools/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F2765%2Fsubarray-sum-multiple-of-k). Opening a form does not execute a tool.