From 7d5b56210f37ef5c13bbfa28bf8833398719eff8 Mon Sep 17 00:00:00 2001 From: chayan das Date: Tue, 25 Nov 2025 01:24:39 +0530 Subject: [PATCH] Create 1018. Binary Prefix Divisible By 5 --- 1018. Binary Prefix Divisible By 5 | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 1018. Binary Prefix Divisible By 5 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; + } +};