MCPcopy Create free account
hub / github.com/Hazrat-Ali9/Computer-Programming / removeDuplicateElements

Method removeDuplicateElements

Problem15.java:8–29  ·  view source on GitHub ↗
(int[] arrayWithDuplicates)

Source from the content-addressed store, hash-verified

6public 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);

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected