gy21
BAN USER
Comments (5)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
//give a1b2c3
//return abbccc
String tostring(String s){
char [] array = new char[20];
TreeMap<Character,Integer> map = new TreeMap<>();
for(int i=0;i<s.length();i=i+2){
map.put(s.charAt(i), Character.getNumericValue(s.charAt(i+1)));
}
int count = 0;//index to track
for(Character c:map.keySet()){
for(int k=count;k<map.get(c)+count;k++){
array[k] = c;
}
count = map.get(c)+count;
}
return new String(array);
}
Comment hidden because of low score. Click to expand.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
- gy21 March 06, 2013