you 1indexed binary string length n bit 0 initially we flip bit binary string ie change 0 1 you give 1indexed integer array flip flipsi indicate bit index flip ith stepA binary string prefixaligne ith step bits inclusive range 1 one bit zerosreturn number time binary string prefixaligne flipping process Example 1input flip 32415output 2explanation the binary string initially 00000after apply step 1 the string 00100 prefixalignedafter apply step 2 the string 01100 prefixalignedafter apply step 3 the string 01110 prefixalignedafter apply step 4 the string 11110 prefixalignedafter apply step 5 the string 11111 prefixalignedwe string prefixaligne 2 time return 2example 2input flip 4123output 1explanation the binary string initially 0000after apply step 1 the string 0001 prefixalignedafter apply step 2 the string 1001 prefixalignedafter apply step 3 the string 1101 prefixalignedafter apply step 4 the string 1111 prefixalignedwe string prefixaligne 1 time return 1 Constraintsn flipslength1 n 5 104flips permutation integer range 1 n