From 92ed8dbf06203013c587763646459d7b0a449446 Mon Sep 17 00:00:00 2001 From: Keerthana Srinivasan Date: Thu, 9 Dec 2021 19:34:42 -0500 Subject: [PATCH] Done --- .../looplabs/IntegerDuplicateDeleter.java | 65 +++++++++++++++++++ .../looplabs/StringDuplicateDeleter.java | 63 ++++++++++++++++++ 2 files changed, 128 insertions(+) diff --git a/src/main/java/com/zipcodewilmington/looplabs/IntegerDuplicateDeleter.java b/src/main/java/com/zipcodewilmington/looplabs/IntegerDuplicateDeleter.java index ee550c5..168604b 100644 --- a/src/main/java/com/zipcodewilmington/looplabs/IntegerDuplicateDeleter.java +++ b/src/main/java/com/zipcodewilmington/looplabs/IntegerDuplicateDeleter.java @@ -1,8 +1,73 @@ package com.zipcodewilmington.looplabs; +import java.util.Arrays; + /** * Created by leon on 1/29/18. * @ATTENTION_TO_STUDENTS You are forbidden from modifying the signature of this class. */ public final class IntegerDuplicateDeleter extends DuplicateDeleter { + + public IntegerDuplicateDeleter(Integer[] intArray){ + super(intArray); + } + + public Integer[] removeDuplicates(int maxNumberOfDuplications) { + Integer[] arrayCount = new Integer[array.length]; + for (int i = 0; i < array.length; i++) { + int count = 0; + for (int j = 0; j < array.length; j++) { + if (array[i] == array[j]) { + count = count + 1; + } + } + if (count < maxNumberOfDuplications) { + arrayCount[i] = array[i]; + } + + } + return removeNullValues(arrayCount); + } + + public Integer[] removeDuplicatesExactly(int exactNumberOfDuplications){ + Integer[] arrayCount = new Integer[array.length]; + for(int i = 0; i { + + public StringDuplicateDeleter(String[] intArray) { + super(intArray); + } + + public String[] removeDuplicates(int maxNumberOfDuplications) { + String[] arrayCount = new String[array.length]; + for (int i = 0; i < array.length; i++) { + int count = 0; + for (int j = 0; j < array.length; j++) { + if (array[i] == array[j]) { + count = count + 1; + } + } + if (count < maxNumberOfDuplications) { + arrayCount[i] = array[i]; + } + + } + return removeNullValues(arrayCount); + } + public String[] removeDuplicatesExactly(int exactNumberOfDuplications){ + String[] arrayCount = new String[array.length]; + for(int i = 0; i