Here is the interview question prompt, presented for reference.
Imagine you're attending a magical carnival where you can pull adjacent duplicate letters from a string like pulling rabbits out of a hat. Exciting, right? Your goal is to get a clean string with no adjacent duplicates. In this lesson, we'll explore this problem with Linda's candy adventure.
Linda loves candies and messages, so she wants to write a message on her cake with candies. However, she can't have adjacent duplicate candies; they need to be unique. Can you help her?
Objective: Help Linda by removing all adjacent duplicate letters until you get a string with no adjacent duplicates.
Starting String: Linda's bag of candies spells out "abbaca".
Step 1: Spot the first adjacent duplicate "bb". These candies can't be together. Remove them!
- Result: "aaca"
- Result: "ca"
And voila! We're left with a string that doesn't have any adjacent duplicates, and it spells out "ca".
![Visual Example](https://storage.googleapis.com/algodailyrandomassets/curriculum/easy-strings/remove-adjacent-duplicates/problem.png)
s
will be between 1 and (105).s
will only consist of lowercase English letters.You can see the full challenge with visuals at this link.
Challenges • Asked over 2 years ago by Jake from AlgoDaily
This is the main discussion thread generated for Remove All Adjacent Duplicates In String (Main Thread).