Super Reduced String ⬀
Reduce a string of lowercase characters in range ascii[‘a’..’z’] by doing a series of operations. In each operation, select a pair of adjacent letters that match, and delete them.
Delete as many characters as possible using this method and return the resulting string. If the final string is empty, return Empty String
s = 'aab'
aab shortens to b in one operation: remove the adjacent a characters.
s = 'abba'
Remove the two 'b' characters leaving 'aa'. Remove the two 'a' characters to leave ''. Return 'Empty String'.
Complete the superReducedString function in the editor below.
superReducedString has the following parameter(s):
string s: a string to reduce
string: the reduced string or Empty String
A single string, s.
1 ≤ length of s ≤ 100
aaabccddd
abd
Perform the following sequence of operations to get the final string:
aaabccddd → abccddd → abddd → abd
aa
Empty String
aa → Empty String
baab
Empty String
baab → bb → Empty String