Determine winner in stack-merging game | Google Interview Question