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

Class Problem15

Problem15.java:6–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4import java.util.Scanner;
5
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);
33 String res = "";
34
35 for (int i = 0; i < n; i++) {
36 while (i < n - 1 && arr[i] == arr[i + 1])
37 i++;
38
39 res = res + Integer.toString(arr[i]);
40 }
41 return res;
42 }
43
44 public static void main(String[] args) {
45 // TODO Auto-generated method stub
46 Scanner input = new Scanner(System.in);
47 int firstNumber, secondNumber;
48 String firstNumberStr, secondNumberStr;
49 String[] results;
50 String result;
51
52 int T = input.nextInt();
53
54 while (T < 1) {
55 T = input.nextInt();
56 }
57 results = new String[T];
58
59 for (int i = 0; i < T; i++) {
60 firstNumber = input.nextInt();
61
62 while (Integer.toString(firstNumber).length() != 2) {
63 firstNumber = input.nextInt();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected