Leetcode Problem 1544. Make The String Great

1544. Make The String Great

Leetcode Solutions

Approach: Stack

  1. Initialize an empty stack stack.
  2. Iterate over each character currChar in the string s.
    • If stack is not empty and currChar pairs with the last character in stack (difference in ASCII values is 32), pop the last character from stack.
    • Otherwise, push currChar onto stack.
  3. After the iteration, construct the good string by popping all characters from stack and reversing the order.
  4. Return the good string.
UML Thumbnail

Approach: Iteration

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...