Sketch on a paper
Sometimes when you sketch something on a paper, solution comes easily. This one for example, I tried the most simplistic solution with a Big Integer, but ran into TLE. Looked at the hints, then you need to figure out the remainder i given the remainder i-1 (to some degree, this becomes a DP problem). On a piece of paper the relationship between i and i-1 becomes very obvious. Code is down below, cheers, ACC. Find the Divisibility Array of a String - LeetCode 2575. Find the Divisibility Array of a String Medium 204 9 Add to List Share You are given a 0-indexed string word of length n consisting of digits, and a positive integer m . The divisibility array div of word is an integer array of length n such that: div[i] = 1 if the numeric value of word[0,...,i] is divisible by m , or div[i] = 0 otherwise. Return the divisibility array of word . ...