Uber Interview Question

random shuffle question from leetcode