← All problemsSign in

Flipping the bits

There is a bit-string S of length N (0- indexed) which can contain only 0s and 1s. Initially, all the bits are 0. Now you have to perform two types of operations: 1) Flip all the bits between s[x] and s[y] (both inclusive). This is represented by the command "0 x y" 2) Answer how many bits between s[x] and s[y] (both inclusive) are 1. This is represented by the command "1 x y". Input The first

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start