(String str)
| 75 | } |
| 76 | |
| 77 | public static String compressAlternate(String str) { |
| 78 | int size = countCompression(str); |
| 79 | if (size >= str.length()) { |
| 80 | return str; |
| 81 | } |
| 82 | char[] array = new char[size]; |
| 83 | int index = 0; |
| 84 | char last = str.charAt(0); |
| 85 | int count = 1; |
| 86 | for (int i = 1; i < str.length(); i++) { |
| 87 | if (str.charAt(i) == last) { |
| 88 | count++; |
| 89 | } else { |
| 90 | index = setChar(array, last, index, count); |
| 91 | last = str.charAt(i); |
| 92 | count = 1; |
| 93 | } |
| 94 | } |
| 95 | index = setChar(array, last, index, count); |
| 96 | return String.valueOf(array); |
| 97 | } |
| 98 | |
| 99 | public static void main(String[] args) { |
| 100 | String str = "abbccccccde"; |
no test coverage detected