LeetCode icon indicating copy to clipboard operation
LeetCode copied to clipboard

1375. Number of Times Binary String Is Prefix-Aligned

Open Arya-Gupta opened this issue 2 years ago • 1 comments

https://leetcode.com/problems/number-of-times-binary-string-is-prefix-aligned/

Arya-Gupta avatar Apr 14 '22 11:04 Arya-Gupta

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; } };

Thanh-Van-2001 avatar Sep 09 '22 05:09 Thanh-Van-2001