Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Use a stack solution in Speedy category for Adjacent Letters by amandel
def adjacent_letters(line: str) -> str:
out=[]
for x in line:
if not out or out[-1] != x:
out.append(x)
else:
out.pop()
return ''.join(out)
print("Example:")
print(adjacent_letters("abbaca"))
assert adjacent_letters("adjacent_letters") == "adjacent_lrs"
assert adjacent_letters("") == ""
assert adjacent_letters("aaa") == "a"
assert adjacent_letters("ABBA") == ""
print("The mission is done! Click 'Check Solution' to earn rewards!")
Sept. 12, 2022
Comments: