Implement streaming k-way merge with constraints | Amazon