Skip to content

[Prefix Sum] Continuous Subarray Sum #55

@sudosf

Description

@sudosf

Problem

Given an integer array and k, return true if there is a subarray of length at least 2 whose sum is a multiple of k.

References

Difficulty

🟡 Medium

Companies

Facebook, DE Shaw, Sumo Logic

Notes

Language: Java
Store prefix sum mod k in a map. If the same remainder appears again with at least 2 elements between, you have a valid subarray.

Metadata

Metadata

Assignees

No one assigned

    Labels

    arraysArray problemshashmapHashmap and set problemsmediumMedium difficultyprefix-sumPrefix sum pattern

    Projects

    Status
    Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions