Skip to content

Instantly share code, notes, and snippets.

Created Nov 25, 2021
What would you like to do?

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