TORONTO KIDS COMPUTER CLUB | PMCA Saturday 18:30 Python Homework 21.08.14.
post-template-default,single,single-post,postid-19838,single-format-standard,ajax_fade,page_not_loaded,,no_animation_on_touch,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

PMCA Saturday 18:30 Python Homework 21.08.14.

21 Aug PMCA Saturday 18:30 Python Homework 21.08.14.

You are given a string ‘s’ consisting of lowercase English letters. A duplicate removal consists of choosing two adjacent and equal letters and removing them.

We repeatedly make duplicate removals on s until we no longer can.

Return the final string after all such duplicate removals have been made. It can be proven that the answer is unique.

Example 1:
s = "abbaca"


For example, in "abbaca" we could remove "bb" since the letters are adjacent and equal, and this is the only possible move.  The result of this move is that the string is "aaca", of which only "aa" is possible, so the final string is "ca".

Example 2:
s = "azxxzy"

No Comments

Sorry, the comment form is closed at this time.