Remove All Adjacent Duplicates in String II
Medium · Stack & Monotonic Stack · about 15 minutes
Asked at Amazon, Salesforce, Twilio, Meta, Bloomberg, Okta, HubSpot.
Whenever s contains k identical letters in a row, delete that run; deletions can bring new runs together, so keep going until no run of k equal letters is left. Return what remains (the final string does not depend on the order of deletions).