Skip to content

Make The String Great

EasyStack
Decode it first. Clues, constraints, pattern and plan before any code.

A string is bad if it has two adjacent characters that are the same letter in different cases, such as "aA" or "Bb". Given a string s of English letters, keep deleting such pairs until the string is good, and return it. An empty string is good.

s = "leEeetcode"  →  "leetcode"   ("eE" or "Ee" cancels)
s = "abBAcC"      →  ""           ("bB" goes, then "aA", then "cC")
s = "s"           →  "s"

Constraints

  • 1 <= s.length <= 100
  • s contains only lowercase and uppercase English letters.