It works fine when i run it on my ide. Gives error on submission.
Check the last condition please.
package com.codegym.task.task08.task0814;
import java.util.*;
import java.util.HashSet;
import java.util.Set;
/*
Greater than 10? You're not a good fit for us
*/
public class Solution {
public static HashSet<Integer> createSet() {
// write your code here
HashSet<Integer> set = new HashSet<Integer>(20);
for(int i = 1; i <= 20; i++)
{
set.add(i);
}
return set;
}
public static HashSet<Integer> removeAllNumbersGreaterThan10(HashSet<Integer> set) {
// write your code here
int quarantine[] = new int[200];
int t = 0;
Iterator<Integer> iterator = set.iterator();
while (iterator.hasNext()) // Check if there is another element
{
// Get the current element and move to the next one
Integer k = iterator.next();
// if(t != 0)
// {
// System.out.println(t + " B " + quarantine[t-1]);
// }
if(k > 10)
{
quarantine[t++] = k;
}
// System.out.println(t + " A " + quarantine[t]);
}
for(Integer rem : quarantine)
{
set.remove(rem);
}
return set;
}
public static void main(String[] args) {
}
}