Comments

ooooo... ok i get it, Ty

I have a doubt in the solution code of problem C

for(int a1 = a; a1 < b; a1++) {
            int b1 = 0;
            for(int i = 21; i >= 0; i--) {
                if((b >> i) & 1) {
                    b1 ^= (1 << i);
                } else {
                    if((a1 >> i) & 1) {
                        b1 ^= (1 << i);
                        break;
                    }
                }
            }
            ans = min(ans, a1 - a - b + (a1 | b1) + 1);
        }

why have they chosen the inner lop to range from 21 to 0? Can somebody pls explain it to me

On 300iqGood Bye 2021 -- Editorial, 4 years ago
0

hey, how should I decide up to how many decimal precision should I set the range for the check, like why have you chosen 0.000001 and not 0.00001 or 0.0000001?

Can u please explain in detail, coz I'm pretty bad with floats, doubles and precisions...

On 300iqGood Bye 2021 -- Editorial, 4 years ago
0

consider the example:

INDEX   :          12345678     
string 1: cba -->  cbaabc
string 2: cbaa --> cbaaaabc

The string 2 is lexicographically smaller than string 1, because the first position where the two characters differ is at index 5 . string_1[5] = 'b' > string_2[5] = 'a'.

Hence the o/p of string 2 is lexicographically the smallest.

Hope I'm making sense.