Solve sliding-window, flattening, decode, and O(1) random set | Bloomberg Interview Question