Skip to content

Instantly share code, notes, and snippets.

@azs06
Created November 25, 2021 12:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azs06/08569c519b40182c07c2a0288aaec5f1 to your computer and use it in GitHub Desktop.
Save azs06/08569c519b40182c07c2a0288aaec5f1 to your computer and use it in GitHub Desktop.
problem

You are given a string: candies, which is composed of chars from the English alphabet. If you see two consecutive candies that are the same, you pop them from left to right, until you cannot pop any more candies. Return the resulting string.

// candies = "abba"
// "abba" - pop the two b's -> "aa"
// "aa" - pop the two a's -> ""
// return ""
// candies = "abcd"
// return "abcd"
// candies = "aaa"
// "aaa" - pop two a's -> "a"
// return "a"
// candies = "abbba"
// "abbba" - pop two b's ->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment