Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.
class Test {
public static void main(String args[]) {
System.out.println(makeShort("ABBCCCDD"));
}
public static String makeShort(String in) {
StringBuffer out = new StringBuffer();
int j=1,i=1;
for(; i<in.length(); i++) {
if(in.charAt(i) == in.charAt(i-1))
j++;
else {
if(j>1)
out.append(in.charAt(i-1)).append(j);
else
out.append(in.charAt(i-1));
j=1;
}
}
out.append(in.charAt(i-1));
if(j>1)
out.append(j);
return out.toString();
}
}
jo, ist doch ein klassisches Kompressionsverfahrenund dann dekodiert,
von ABBC3D4
zu ABBCCCDDDD zurück