Solve Sherlock's Array Merging Algorithm

Help Sherlock reverse-engineer the inputs he used to merge k arrays with a given algorithm. Solving code challenges on HackerRank is one of the best ways to prepare for programming interviews.