Shawn's Blog

  • Home
  • Tags
  • Categories
  • Archives
  • Search
  • Table of Contents
  • Overview

Shawn

若有恒,何必三更眠五更起;最无益,莫过一日曝十日寒。
392 posts
13 categories
114 tags

LeetCode 1018. Binary Prefix Divisible By 5

Posted on 2021-01-14 Edited on 2024-11-24 In LeetCode
1
2
3
4
5
6
7
8
9
10
11
12
class Solution {
public:
vector<bool> prefixesDivBy5(vector<int>& A) {
vector<bool> ans;
int mask = 0;
for (const int i : A) {
mask = ((mask << 1) + i) % 5;
ans.emplace_back(mask == 0);
}
return ans;
}
};
# Array
LeetCode 684. Redundant Connection
LeetCode 947. Most Stones Removed with Same Row or Column
© 2024 Shawn
Powered by Hexo & NexT.Mist
0%