I\'m trying to get a head start on practicing interview questions and I came across this one:
Turn String aaaabbbbffffd into a4b4d3
You would basically want t
Here is my solution
public String countChars(String in){
LinkedHashMapMap map = new LinkedHashMap();
for(char c: in.toCharArray()){
Integer count = map.get(c);
if(count==null){
count=0;
}
count++;
map.put(c,count);
}
String out ="";
for(Entry e : map.entrySet()){
out += e.getKey()+e.getValue();
}
return out;
}