Wave Sort Problem

What if a repetitive element occurs ??


u can refer to this method
this is my submiited solution on leetcode
problem : https://leetcode.com/problems/wiggle-sort-ii/
some solutions are also available on this site: http://tiancao.me/Leetcode-Unlocked/LeetCode%20Locked/c1.42.html