private void appendLastCharIfNeeded(StringBuilder stringBuilder, int repeatedCharCounter,
      char previousChar) {
    if (repeatedCharCounter > 1) {
      addChar(stringBuilder, previousChar);
      stringBuilder.append(repeatedCharCounter);
    }
  }
Time complexity O(n) Space complexity O(n)
First while loop for finding repeat groups, and inner while loop is for finding same characters
src/main/java/com/github/pedrovgs/problem53/CompressString.java