Uber interview question

random shuffle question from leetcode