CodePudding user response:
The compression of the string, online search a lot ofCodePudding user response:
Don't ababab output? This condition is bizarreCodePudding user response:
Use regular expressions to match,CodePudding user response:
Import the Java. Util. *;Class a {
Public static void main (String [] args) {
String STR="aaabbbccef";
Map
for(int i=0; i
if(! Maps. Either containsKey (key))
Maps. The put (key, 1);
The else {
Int val=maps. Get (key);
Maps. The put (key, val + 1);
}
}
String tem="";
For (Map) Entry I: maps. EntrySet ()) {
If ((int) i.g etValue ()==1) {
Tem +=i.g etKey ();
} else {
Tem +=i.g etKey () + "" + i.g etValue ();
}
}
System. The out. Println (tem);
}
}