public String getRepeatedCharsAsString(String one, String two) {
        Map<Character, Integer> charFrequency;
        StringBuilder builder = new StringBuilder();
        String longer;
        if (one.length() > two.length()) {
            charFrequency = makeCharFrequencyMap(two);
            longer = one;
        } else {
            charFrequency = makeCharFrequencyMap(one);
            longer = two;
        }
        boolean done = false;
        String values = keysToString(charFrequency.keySet());
        for (int i = 0; i < values.length() ; i++) {
            if (charFrequency.isEmpty()) {
                done = true;
            } else {
                int frequency = charFrequency.get(values.charAt(i));
                int index = longer.indexOf(values.charAt(i));
                if (index != -1 && frequency > 0) {
                    builder.append(values.charAt(i));
                    charFrequency.put(values.charAt(i), --frequency);
                    while (frequency > 0 && !done) {
                        frequency = charFrequency.get(values.charAt(i));
                        index = longer.indexOf(values.charAt(i), ++index);
                        if (index == -1 || frequency < 1) {
                            done = true;
                        } else {
                            charFrequency.put(values.charAt(i), --frequency);
                            builder.append(values.charAt(i));
                        }
                    }

                }

                charFrequency.remove(values.charAt(i));

            }
        }

        return builder.toString();
    }