We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Logic is as follows: 1. Add first character to stack 2. if last element added in stack(element in TOP) is same as next character scanned then it means two elements are adjacent so we pop. This removes adjacent same characters. 3. The characters remaining in stack are your reduced string.
Super Reduced String
You are viewing a single comment's thread. Return to all comments →
Logic is as follows: 1. Add first character to stack 2. if last element added in stack(element in TOP) is same as next character scanned then it means two elements are adjacent so we pop. This removes adjacent same characters. 3. The characters remaining in stack are your reduced string.