Domanda di colloquio di Amazon

Asked to rearrange an array such that no 2 adjacent elements are same.