static String compress(String s) {
        if (countCompress(s) >= s.length()) {
            return s;
        }
        StringBuffer sb = new StringBuffer();
        char[] charArray = s.toCharArray();
        char currentChar = '\0';
        int count = 0;

        for (char ch: charArray) {
            if (ch == currentChar) {
                count += 1;
            } else {
                if (currentChar != '\0'){
                    sb.append(currentChar).append(count);
                }
                currentChar = ch;
                count = 1;
            }
        }

        sb.append(currentChar).append(count);
        return sb.toString();
    }