Merge K sorted algorithm