Question bank › Prefix Sum
Dsa Prefix Sum Medium

Continuous Subarray Sum with Rules

Write a program that takes an array of integers and determines if there exists a continuous subarray (at least size 2) that sums up to a multiple of a specified integer k. Input format: - The first line contains two integers, n (number of elements) and k (the divisor). - The second line contains n integers (the elements of the array). Output format: - Print 'True' if such a subarray exists, otherwise print 'False'. Example: Input: 5 3 23 2 4 6 7 Output: True

Key concepts

prefix_sumsubarraymodulo

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.