What about the case: 0 0 0 0 0 X X X and the case: 0 0 0 0 X 0 X X


in the first case we shouldn’t move the seats at all (total moves:0)
and in the second case we should move the leftmost X to it’s right (total moves:1)

I don’t see why the median is the correct solution here… it’ll result in much more moves


I think you are confusing between mean and median. Here it means median of all the indexes which have x.