Skip to content

[Prefix Sum] Subarray Sums Divisible by K #56

@sudosf

Description

@sudosf

Problem

Given an integer array and k, return the number of non-empty subarrays that have a sum divisible by k.

References

Difficulty

🟡 Medium

Companies

Goldman Sachs, Microsoft, PayPal

Notes

Language: Java
Same mod-map pattern as Continuous Subarray Sum but counting all occurrences. Handle negative remainders in Java with ((sum % k) + k) % k.

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