123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
-
-
-
- public class IntegerDuplicateDeleter extends DuplicateDeleter<Integer>{
-
- Integer[] stringArr;
-
- public IntegerDuplicateDeleter(Integer[] array) {
- super(array);
- }
-
- public Integer[] removeDuplicates(int n){
- Integer[] newArr = new Integer[0];
- int count = 0;
- for(int i = 0; i < array.length; i++) {
- for(int j = 0; j < array.length; j++) {
- if(i == j) {
- count++;
- }
- }
- if(count < n) {
- Integer[] temp = new Integer[newArr.length + 1];
- for(int k = 0; k < newArr.length; k++) {
- temp[k] = newArr[k];
- }
- temp[temp.length - 1] = i;
- newArr = temp;
- }
- }
- Integer[] newArr2 = new Integer[]{};
- if(newArr.length == 1 && newArr[0] == 0) {
- return newArr2;
- }
- else{ return newArr;
- }
- }
-
- public Integer[] removeDuplicatesExactly(int n) {
- Integer[] newArr = new Integer[0];
- int count = 0;
- for(int i : array) {
- for(int j : array) {
- if(j == i) {
- count++;
- }
- }
- if(count != n) {
- Integer[] temp = new Integer[newArr.length + 1];
- for(int k = 0; k < newArr.length; k++) {
- temp[k] = newArr[k];
- }
- temp[temp.length - 1] = i;
- newArr = temp;
- }
- }
- return newArr;
- }
- }
-
|