hackerrank/interview_preparation_kit_string_manipulation.rb
# Complete the alternatingCharacters function below.

Complete the alternatingCharacters function below.
Complete the alternatingCharacters function below .
def alternatingCharacters(s)
  previous_char = ""
  cnt = 0
  s.chars do |c|
    if c == previous_char
      cnt += 1
    end
    previous_char = c
  end
  cnt
end
def alternatingCharacters ( s ) previous_char = "" cnt = 0 s . chars do | c | if c == previous_char cnt += 1 end previous_char = c end cnt end
Complete the alternatingCharacters function below.
Complete the alternatingCharacters function below .
s
<not_specific>