Advertisement
And1

tets9

Mar 5th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. import java.util.Iterator; import java.util.Set; public class Test9 { public static void main(String[] args) { int[] in = new int[] { 60, 10, 50, 40, 30, 100 }; Set<Integer> a = new IntSparseSet(-100, 101) {{ for (int x : in) add(x); }}; Iterator<Integer> it = a.iterator(); while (it.hasNext()) { int x = it.next(); if (x == 10 || x == 30) it.remove(); } int i = 0; int[] out = new int[] { 60, 100, 50, 40 }; for (int x : a) Assert.assertEquals(out[i++], x); System.out.println("PASSED"); } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement