I have an array which consist of duplicate elements e.g.
arr = [1, 2, 3, 0, 2, 1]
Now, I want to store elements in a stack in such a way that