Shortest 11 Problem 200

Beautiful String  

Beautiful String

One string is beautiful if there are at least two consecutive equal characters.

  Strings "abba", "hello", "collection", "egg" are beautiful
  String "aba", "earth", "world" are not beautiful
Given a string, find out what is the minimal number of characters to be removed in order to make the string beautiful.

If there is no way to make the string beautiful, return -1

Input parameters:
   string to be beautified

  the size of string is between 1 and 100 inclusive
  each character of number is between 'a' and 'z' inclusive

Return value:
  The minimal number of characters to be removed to make the string beautiful or -1 if it is not possible
Class Name:

Method signature:
  public int remove(String string)

Test Case 1:
  remove("abba") = 0

Test Case 2:
  remove("hello") = 0

Test Case 3:
  remove("egg") = 0

Test Case 4:
  remove("x") = -1

Test Case 5:
  remove("aba") = 1

Test Case 6:
  remove("world") = -1

Test Case 7:
  remove("nfsloxcpfijv") = 6

Test Case 8:
  remove("fdcsaytrntdlrv") = 2

Test Case 9:
  remove("dywvcafnovmcqxkpw") = 5

Test Case 10:
  remove("jqpxdewvhytufj") = 12