What do you want to save?
Add Code snippet
New code examples
-
Java 2021-11-18 20:22:24
convert hashset to array
// First of all, you shouldn't use raw types. // Use : Set<Integer> set = new HashSet<>(); set.add(4); set.add(1); // Then convert to array : Integer[] arr = x.toArray(new Integer[set.size()]); // Using x.toArray() would give you an Object[]. Add solution -
Java 2021-09-15 12:44:03
smallest positive integer not in array java
If the expected running time should be linear, you can't use a TreeSet, which sorts the input and therefore requires O(NlogN). Therefore you should use a HashSet, which requires O(N) time to add N elements. Besides, you don't need 4 loops. It's sufficien... Add solution
Best helpers
Ranking is empty