This question evaluates understanding of modular arithmetic, contiguous subarray sums, and streaming-aware algorithm design, measuring competency in array processing, remainder reasoning, and handling edge cases such as k = 0.
Given an integer array nums and an integer k, determine whether there exists a contiguous subarray of length at least 2 whose sum is divisible by k; return true if such a subarray exists, otherwise false. If k = 0, interpret the requirement as finding a length ≥2 subarray with sum exactly 0. Explain your approach and analyze time and space complexity. Follow-up: how would you adapt your solution to a streaming setting where nums arrives incrementally?