Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
We can check if the numeric value of the prefix of the given string is divisible by m by computing the remainder of the numeric value of the prefix when divided by m.
The remainder of the numeric value of a prefix ending at index i can be computed from the remainder of the prefix ending at index i-1.