Check all subarrays of length at least 2. For each, compute the sum and check if it's divisible by k.
There are subarrays. Even with prefix sums making each sum , that's still .
For , that's operations. Too slow.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
The trap
Check all subarrays of length at least 2. For each, compute the sum and check if it's divisible by k.
There are subarrays. Even with prefix sums making each sum , that's still .
For , that's operations. Too slow.