Skip to content
Decoder

Make The String Great

Easy

Problem

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.

Example 1

Input
s = "leEeetcode"
Output
"leetcode"
Why
"eE" or "Ee" cancels

Example 2

Input
s = "abBAcC"
Output
""
Why
"bB" goes, then "aA", then "cC"

Example 3

Input
s = "s"
Output
"s"

Constraints

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

Read it once before you touch anything

Want some pressure? Start the timer. In an interview you get about two minutes to understand the problem.

  1. 1Read the goalWhat goes in, what comes out
  2. 2Scan the examplesCheck one by hand
  3. 3Note the constraintsThey set your Big O
Say what it asks in one sentence
Say it out loud first, then compare with ours.