Hackerrank - Super Reduced String

Hackerrank - Problem Statement

A description of the problem can be found on Hackerrank.

Solution

I created an accumulator with initial value as empty string. I iterated through each character and updated the accumulator

  • if an actual character is equals to last accumulator character, delete this character from the accumulator
  • else append the character to the accumulator

The result is the accumulator after the iteration.

I created solution in:

All solutions are also available on my GitHub.

Java

JavaScript

Scala

Ruby

Leave a Reply