codeChallenge/Amazon.java
dadgam3er c5974fe278
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 11s
Gitea Actions Demo / GoBuild (push) Failing after 5s
anoterCode
2024-09-11 23:21:31 -04:00

37 lines
994 B
Java

import java.util.ArrayList;
import java.util.Collections;
public class Amazon {
public static void main(String[] args) {
int[] arr = { 4, 4, 4, 4, 1, 1, 1, 1, 1, 6, 6, 6, 6, 3, 3, 3, 3, 2, 2, 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 };
ArrayList<Integer> al = new ArrayList<>();
ArrayList<Integer> all = new ArrayList<>();
for (int d = 0; d < arr.length; d++) {
Collections.sort(all);
all.add(arr[d]);
}
// for (int i = 0; i < arr.length; i++) {
// System.out.print(arr[i]);
// System.out.print("\t");
// al.add(arr[i]);
// }
// System.out.println("");
// System.out.println(al);
for (int i = 0; i < arr.length; i++) {
int p = 0;
if (!al.contains(arr[i])) {
al.add(arr[i]);
p++;
for (int j = 1 + i; j < arr.length; j++) {
if (arr[i] == arr[j]) {
p++;
}
}
System.out.println(arr[i] + " ==>" + p);
}
}
System.out.println(all);
}
}