@@ -0,0 +1,1985 @@
+package coding4fun;%0A%0Aimport java.util.Arrays;%0Aimport java.util.Iterator;%0Aimport java.util.LinkedList;%0Aimport java.util.List;%0A%0A/**%0A * Create an alternating iterator from a list of iterators.%0A *%0A * %3Cpre%3E%0A * Input:%0A * - Iterator 1: 0%0A * - Iterator 2: 1, 2, 3%0A * - Iterator 3: 4, 5%0A * - Iterator 4: 6, 7, 8, 9%0A * - Iterator 5: 10%0A *%0A * Output: 0 1 4 6 10 2 5 7 3 8 9%0A * %3C/pre%3E%0A */%0Apublic class Problem33 %7B%0A    private static class AlternatingIterator implements Iterator%3CInteger%3E %7B%0A        private final LinkedList%3CIterator%3CInteger%3E%3E iterators;%0A        private Iterator%3CIterator%3CInteger%3E%3E iter;%0A%0A        public AlternatingIterator(LinkedList%3CIterator%3CInteger%3E%3E iterators) %7B%0A            this.iterators = iterators;%0A            iter = iterators.iterator();%0A        %7D%0A%0A        @Override%0A        public boolean hasNext() %7B%0A            return iterators.size() %3E 0;%0A        %7D%0A%0A        @Override%0A        public Integer next() %7B%0A            if (!iter.hasNext() && iterators.size() %3E 0) %7B%0A                iter = iterators.iterator();%0A            %7D%0A            Iterator%3CInteger%3E it = iter.next();%0A            Integer val = it.next();%0A            if (!it.hasNext()) %7B%0A                iter.remove();%0A            %7D%0A            return val;%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        List%3CInteger%3E list0 = Arrays.asList(0);%0A        List%3CInteger%3E list1 = Arrays.asList(1, 2, 3);%0A        List%3CInteger%3E list2 = Arrays.asList(4, 5);%0A        List%3CInteger%3E list3 = Arrays.asList(6, 7, 8, 9);%0A        List%3CInteger%3E list4 = Arrays.asList(10);%0A%0A        LinkedList%3CIterator%3CInteger%3E%3E list = new LinkedList%3C%3E();%0A        list.add(list0.iterator());%0A        list.add(list1.iterator());%0A        list.add(list2.iterator());%0A        list.add(list3.iterator());%0A        list.add(list4.iterator());%0A        AlternatingIterator iter = new AlternatingIterator(list);%0A        while (iter.hasNext()) %7B%0A            System.out.print(iter.next() + %22 %22);%0A        %7D%0A        System.out.println();%0A    %7D%0A%7D%0A

Add problem 33