public String rearrangeString(int d, String s){
		Map<Character, Integer> letterMap = new HashMap<Character, Integer>();
		for(int i=0; i<s.length(); i++){
			if(letterMap.containsKey(s.charAt(i))){
				letterMap.put(s.charAt(i), letterMap.get(s.charAt(i))+1);
			}
			else{
				letterMap.put(s.charAt(i), 1);
			}
		}
		
		List<letterAndFrequency> frequencyList = new ArrayList<letterAndFrequency>();
		for(Character c : letterMap.keySet()){
			frequencyList.add(new letterAndFrequency(c, letterMap.get(c)));
		}
		Collections.sort(frequencyList);
		
		
		char[] arrayOutput = new char[s.length()];
		int overallPosition = 0;
		for(int i=frequencyList.size()-1; i>=0; i--){
			int k=overallPosition;
			for(int j=0; j<frequencyList.get(i).frequency; j++){
				arrayOutput[k] = frequencyList.get(i).c;
				if(k >= s.length()){
					return null;
				}
				k = k + d;			
			}
			overallPosition++;
		}
	
		String stringOutput = String.copyValueOf(arrayOutput);
		return stringOutput;
	}