Data Compression, Programming, Java, Python, Data Analysis.
new StringBuilder(); int n = input.length(); for (int i = 0; i < n; i++) { char current = input.charAt(i); int count = 1; while (i < n - 1 && input.charAt(i) == input.charAt(i + 1)) { count++; i++; } compressed.append(current); compressed.append(count); } return compressed.toString(); } This Java