| 6 | public class Problem15 { |
| 7 | |
| 8 | public static String removeDuplicateElements(int[] arrayWithDuplicates) { |
| 9 | int size = arrayWithDuplicates.length; |
| 10 | String result = ""; |
| 11 | |
| 12 | for (int i = 0; i < size; i++) { |
| 13 | for (int j = i + 1; j < size; j++) { |
| 14 | if (arrayWithDuplicates[i] == arrayWithDuplicates[j]) { |
| 15 | arrayWithDuplicates[j] = arrayWithDuplicates[size - 1]; |
| 16 | size--; |
| 17 | j--; |
| 18 | } |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | int[] arrayWithNoDuplicates = Arrays.copyOf(arrayWithDuplicates, size); |
| 23 | |
| 24 | for (int i = 0; i < arrayWithNoDuplicates.length; i++) { |
| 25 | result = result + String.valueOf(arrayWithNoDuplicates[i]); |
| 26 | } |
| 27 | |
| 28 | return result; |
| 29 | } |
| 30 | |
| 31 | static String getDistinct(int arr[], int n) { |
| 32 | Arrays.sort(arr); |