Make The String Great

Easy Topics Company Tags

Repeatedly remove an adjacent pair when the characters are the same English letter in opposite cases, such as aA or Bb. Continue until no such pair remains and return the resulting string. The result is unique; an empty result is allowed.

Example 1:

Input: s = "a"

Output: "a"

Explanation: A single character has no adjacent pair to remove.

Example 2:

Input: s = "abBA"

Output: ""

Explanation: First remove the adjacent "bB", leaving "aA". Removing that pair leaves an empty string.

Example 3:

Input: s = "aAbB"

Output: ""

Explanation: Remove "aA" and then "bB". Both pairs contain the same letter in opposite cases, so nothing remains.

Constraints:

  • 1 <= s.length <= 100
  • Only lowercase and uppercase English letters occur.


Topics

Company Tags

Please upgrade to NeetCode Pro to view company tags.