LeetCode
LeetCode copied to clipboard
1375. Number of Times Binary String Is Prefix-Aligned
https://leetcode.com/problems/number-of-times-binary-string-is-prefix-aligned/
class Solution { public: int numTimesAllBlue(vector < int > & flips) { int now = 0; // E flips i Wallegff int exp = 1; int res = 0; for(int i = 0;i < flips.size();i++){ now += flips[i]; if(now == exp){ res++; } exp += i + 2; } return res; } };