class ArrayDuplicate {

    public String[] remove(String[] array) {
        int repeatedWords = 0;
        for (int wordIndex = 0; wordIndex < array.length - 1; wordIndex++) {
            for (int comparedWordIndex = 0; comparedWordIndex < array.length - 1 - repeatedWords; comparedWordIndex++) {
                if (comparedWordIndex == wordIndex) {
                    comparedWordIndex++;
                 } else if (array[wordIndex].equals(array[comparedWordIndex])) {
                    String tmp = array[comparedWordIndex];
                    array[comparedWordIndex] = array[array.length - repeatedWords - 1];
                    array[array.length - repeatedWords - 1] = tmp;
                    repeatedWords++;
                }
            }
        }
        return Arrays.copyOf(array, array.length - repeatedWords);
    }

}