CoingBat countPairs Solution

public int countPairs(String str) {
  int c=0;
  if(str.length()<3) return 0;
  if(str.charAt(0)==str.charAt(2)) c+=1;
  return c+countPairs(str.substring(1));
 
}

Comments