Problem 1717 · Medium

Maximum Score From Removing Substrings

Remove ab and ba substrings from a string, scoring each removal with the higher-value pattern first. The visual highlights removable pairs on a stack as the string is scanned.

Open the interactive visualisation