1 Like
Great video.
Which whiteboard software do you use?
As per the explanation in the video editorial the ans for this case
N = 7
money = 8, 16, 32, 64, 4, 4, 4
K = 6
X = 4
will be 148
Can u explain in which order the bags should be picked to get 148 as the answer.
8xor4 = 12, 16xor4 = 20, 32xor4 = 36, 64xor4 = 68, 4xor4 = 0
So we will take (8, 16, 32, 64) because we can increase their values
So this is the case when M as even ( M = 4 ) so it is independent on K.
steps: index of numbers

1, 3, 4, 5, 6, 7

2, 3, 4, 5, 6, 7

3, 5, 6, 7, 1, 2

4, 5, 6, 7, 1, 2
Here You can see that index 1, 2, 3, 4 used an odd number of times so their values are changed.
and index 5, 6, 7 used even num of times so their values remain the same…
Ans = 12+20+36+68+4+4+4 = 148
1 Like
Is this true for all the cases that u could complete in even number of steps?