Question: Given a string, str , the task is to write a complete C + + program that removes all the duplicate adjacent characters from the
Given a string, str the task is to write a complete C program that removes all the duplicate adjacent characters from the given string. The program then prints the characters that remain in the string.
You can assume that the string behaves like an array of characters. You must use a stack in the implementation of your solution. If you are left with an empty string your code should print "Empty String"
tableInputOutputapplealeaabbccEmpty StringaadbbgccdgadgdgaexcellentexcntmaddamEmpty String
Notice that given the choice of a stack for the implementation we are reevaluating the sequence as the letters get removed, and letters get pushed together, as in the last example. After the ds get removed the as become adjacent, and after they are removed the ms become adjacent leaving you with an empty string.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
