diff --git a/1018. Binary Prefix Divisible By 5 b/1018. Binary Prefix Divisible By 5 new file mode 100644 index 0000000..ed48182 --- /dev/null +++ b/1018. Binary Prefix Divisible By 5 @@ -0,0 +1,12 @@ +class Solution { +public: + vector prefixesDivBy5(vector& nums) { + vector ans; + int val = 0; + for (int bit : nums) { + val = (val * 2 + bit) % 5; + ans.push_back(val == 0); + } + return ans; + } +};