← Questions
Flip a binary string and count zeros in a prefix
0
I was asked this
No reports yet. Sign in to say where you were asked it.
You get a binary string and a list of requests. A flip request inverts every bit of the string. A count request with index i asks how many zeros the string currently has from position 0 through i. Return the answers to the count requests in order, without rebuilding the string on each flip: keep prefix counts and a flag for whether the string is currently inverted.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding
