Trains the technique from
LeetCode 523Continuous Subarray SumThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A smart water meter reports the litres drawn on each of a run of consecutive days, given as nums, so nums[i] is the reading for day i. A quiet day reports 0.
The utility settles accounts in windows. A window is a stretch of consecutive days holding two days or more.
Return true when at least one window has a total that is a whole multiple of k, and false when none does. A total of 0 counts as a whole multiple of k.
Example 1
Days 1 and 2 form a window of two days totalling 3 + 9 = 12, which is one whole multiple of 12.
Example 2
The windows available total 11, 7 and 16, and none of those is a multiple of 100.
Example 3
The only window of two days or more is the whole log, totalling 11, which is not a multiple of 7. Day 0 on its own reads 7 but a single day is too short to be a window.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def check_subarray_sum(nums: list[int], k: int) -> bool:public boolean checkSubarraySum(int[] nums, int k)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.