Home Reference Source

src/stack/remove-consecutive-duplicates.ts

// Stacks can be used to remove duplicate characters from a string that are stacked next to each other.
// For example, we take the string aabbccccc and convert it into abc.
// We can push the first character into a stack and skip if the top of the stack is equal to current character.

// Input:
// 2
// aaaaaabaabccccccc
// abbccbcd

// Output:
// ababc
// abcbcd