You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here, we use a stack to solve the problem. If new character occurs we check whether it is on our top of the stack or not, if yes then we pop it. Else if previous character is the same as new character then no need to pop as it is already popped and if neither occurs then append the new(distinct) character.