Free written solution

Binary Prefix Divisible By 5 (LeetCode 1018): Solution and Explanation

Read a binary array one bit at a time, most significant bit first, and report after every bit whether the number read so far is a multiple of 5. With nums = [0,1,1] the prefixes are 0, 1 and 3, so the answer is [true,false,false].

Read the intuition, approach, code and complexity →