How can we do it most efficiently? Given a list with repeated items, task is to rearrange items in a list so that no two adjacent items are same.
Input: [1,1,1,2,3]
Output: [1,2,1,3,1]
Input: [1,1,1,2,2]
Output: [1,2,1,2,1]
Input: [1,1]
Output: Not Possible
Input: [1,1,1,1,2,3]
Output: Not Possible
Edit: General Algorithm is fine too! It doesn't need to be Python.