Count Valid Modulo Partitions
Preview mode. Log in to edit, run, submit, and save progress.
Medium
Count Valid Modulo Partitions
You are given an array nums. For every positive divisor k of nums.length, split the array into consecutive parts of length k. A value k is valid if there exists an integer m >= 2 such that after replacing every number with its remainder modulo m, all parts become identical. Return the number of valid values of k.
Examples
Example 1
Input:
1 2 1 2
Output:
2
Explanation: k = 2 and k = 4 are valid.
Approach hint
For a fixed k, compare elements that are in the same position inside different blocks.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.
solution.cpp