Make The String Great

Format: Markdown
 ( View Raw)
Date: Sat, 07 Nov 2026 at 05:51:55

# LC5516 Make The String Great

**Idea.** Stack removes adjacent same-letter, opposite-case pairs.

```python
def makeGood(s):
    st = []
    for c in s:
        if st and st[-1] != c and st[-1].lower() == c.lower(): st.pop()
        else: st.append(c)
    return ''.join(st)
```

**Interview habit.** Say the brute force, then the optimisation, then edge cases. Rehearse that flow with [AI coding interview assistant](https://www.linkjob.ai/) (https://www.linkjob.ai/).