Hackerrank – Alternating Characters

Problem Statement
A description of the problem can be found on Hackerrank.

Solution
Iterate through all string characters. If actual character i is different then character i-1 then use character i for next comparison. If they are not equal increment a deletion counter. Print the value of the counter.

I created solution in:

All solutions are also available on my GitHub.

Java

JavaScript

Scala

Ruby