Zynga interview question

Algorithm