Transform sparse time-code stream to dense rows | Jane Street Interview Question