Nhu Nguyen 1bdde8e3e3 Revert "convert to bluej" | преди 6 години | |
---|---|---|
src | преди 6 години | |
.gitignore | преди 6 години | |
.travis.yml | преди 6 години | |
README.md | преди 6 години | |
pom.xml | преди 6 години |
Instructions
IntegerDuplicateDeleter
, with a composite Integer[]
object, write a method
removeDuplicatesExactly
which removes all values in the array which occur exactly the specified number of times.removeDuplicates
which removes all values in the array which occur at least the specified number of times.
StringDuplicateDeleter
, with a composite String[]
object, write a method
removeDuplicatesExactly
which removes all values in the array which occur exactly the specified number of times.removeDuplicates
which removes all values in the array which occur at least the specified number of times.Restrictions
Collection
, List
, Map
)removeDuplicateExactly(n)
Sample Script
// : Given
Integer[] array = new Integer[]{1,1,1,23,23,56,57,58};
DuplicateDeleter<Integer> deleter = new IntegerDuplicateDeleter(array);
// : When
Integer[] actual = deleter.removeDuplicateExactly(3);
// : Then
System.out.println(Arrays.toString(actual));
Sample Output
[23,23,56,57,58]
Sample Script
// : Given
Integer[] array = new Integer[]{1,1,1,23,23,56,57,58};
DuplicateDeleter<Integer> deleter = new IntegerDuplicateDeleter(array);
// : When
Integer[] actual = deleter.removeDuplicateExactly(1);
// : Then
System.out.println(Arrays.toString(actual));
Sample Output
[1,1,1,23,23]
Sample Script
// : Given
Integer[] array = new Integer[]{0, 0, 0, 1, 1, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5};
DuplicateDeleter<Integer> deleter = new IntegerDuplicateDeleter(array);
// : When
Integer[] actual = deleter.removeDuplicateExactly(3);
// : Then
System.out.println(Arrays.toString(actual));
Sample Output
[1, 1, 2, 4, 4, 5, 5, 5, 5]
removeDuplicates(n)
Sample Script
// : Given
Integer[] array = new Integer[]{1,1,1,23,23,56,57,58};
DuplicateDeleter<Integer> deleter = new IntegerDuplicateDeleter(array);
// : When
Integer[] actual = deleter.removeDuplicateExactly(1);
// : Then
System.out.println(Arrays.toString(actual));
Sample Output
[]
Sample Script
// : Given
Integer[] array = new Integer[]{0, 0, 0, 1, 1, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5};
DuplicateDeleter<Integer> deleter = new IntegerDuplicateDeleter(array);
// : When
Integer[] actual = deleter.removeDuplicates(2);
// : Then
System.out.println(Arrays.toString(actual));
Sample Output
[2]
Sample Script
// : Given
Integer[] array = new Integer[]{0, 0, 0, 1, 1, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5};
DuplicateDeleter<Integer> deleter = new IntegerDuplicateDeleter(array);
// : When
Integer[] actual = deleter.removeDuplicates(3);
// : Then
System.out.println(Arrays.toString(actual));
Sample Output
[1,1,2,4,4]
Sample Script
// : Given
Integer[] array = new Integer[]{0, 0, 0, 1, 1, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5};
DuplicateDeleter<Integer> deleter = new IntegerDuplicateDeleter(array);
deleter.removeDuplicates(0);
deleter.removeDuplicates(1);
deleter.removeDuplicates(2);
// : When
Integer[] actual = deleter.removeDuplicates(3);
// : Then
System.out.println(Arrays.toString(actual));
Sample Output
[1,1,2,4,4]
Sample Script
// : Given
Integer[] array = new Integer[]{1,1,1,23,23,56,57,58};
DuplicateDeleter<Integer> deleter = new IntegerDuplicateDeleter(array);
deleter.removeDuplicates(0);
deleter.removeDuplicates(1);
deleter.removeDuplicates(2);
// : When
Integer[] actual = deleter.removeDuplicatesExactly(3);
// : Then
System.out.println(Arrays.toString(actual));
Sample Output
[23,23,56,57,58]