<li>Choose an index <code>i</code> in the string, and let <code>c</code> be the character in position <code>i</code>. <strong>Delete</strong> the <strong>closest occurrence</strong> of <code>c</code> to the <strong>left</strong> of <code>i</code> (if exists).</li>
<li>Choose an index <code>i</code> in the string, and let <code>c</code> be the character in position <code>i</code>. <strong>Delete</strong> the <strong>closest occurrence</strong> of <code>c</code> to the <strong>right</strong> of <code>i</code> (if exists).</li>
<li>Operation 2: we choose <code>i = 1</code> so <code>c</code> is 'a', then we remove <code>s[2]</code> as it is closest 'a' character to the right of <code>s[1]</code>.<br/>
<code>s</code> becomes "aabc" after this.</li>
<li>Operation 1: we choose <code>i = 1</code> so <code>c</code> is 'a', then we remove <code>s[0]</code> as it is closest 'a' character to the left of <code>s[1]</code>.<br/>
<code>s</code> becomes "abc" after this.</li>
<li>Operation 1: we choose <code>i = 2</code> so <code>c</code> is 'b', then we remove <code>s[1]</code> as it is closest 'b' character to the left of <code>s[1]</code>.<br/>
<code>s</code> becomes "cbd" after this.</li>
<li>Operation 1: we choose <code>i = 6</code> so <code>c</code> is 'a', then we remove <code>s[2]</code> as it is closest 'a' character to the left of <code>s[6]</code>.<br/>
<code>s</code> becomes "badccab" after this.</li>
<li>Operation 2: we choose <code>i = 0</code> so <code>c</code> is 'b', then we remove <code>s[6]</code> as it is closest 'b' character to the right of <code>s[0]</code>.<br/>
<li>Operation 2: we choose <code>i = 3</code> so <code>c</code> is 'c', then we remove <code>s[4]</code> as it is closest 'c' character to the right of <code>s[3]</code>.<br/>
<code>s</code> becomes "badca" after this.</li>
<li>Operation 1: we choose <code>i = 4</code> so <code>c</code> is 'a', then we remove <code>s[1]</code> as it is closest 'a' character to the left of <code>s[4]</code>.<br/>
<code>s</code> becomes "bdca" after this.</li>