← Questions

Flip a binary string and count zeros in a prefix

0
DatabricksCodingLast asked Aug 2024

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.

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