static public void create(char[] str, int d, char[] res) throws Exception {
		int[] freq = new int[charSize];
		int[] used = new int[charSize];
		
		/*
		 *  find freq of each char
		 */
		for(int i = 0; i < str.length; ++i) {
			freq[str[i]-charBase]++;
		}

		for(int i = 0; i < str.length; ++i) {
			boolean[] except = new boolean[charSize];
			boolean done = false;
			while(!done) {
				int maxC = getCharWithMaxFreq(freq, except);
				if(maxC < 0)
					throw new Exception("error!");
				except[maxC] = true;
				if(used[maxC] <= 0) {
					used[maxC] = d;
					freq[maxC]--;
					res[i] = (char)(maxC + charBase);
					done = true;
				}
			}
			for(int j = 0; j < charSize; ++j)
				used[j]--;
		}
	}