1. * *- *-* *--* -*--* 2. one possible solution: public int digitProduct(int n) { if (n < 0) { return -digitProduct(-n); } else if (n == 0) { throw new IllegalArgumentException(); } else if (n < 10) { return n; } else { int digit = n % 10; if (digit == 0) { return digitProduct(n / 10); } else { return digit * digitProduct(n / 10); } } } 3. one possible solution: public Set whereInTheWorld(String place, Map> where) { Set names = new TreeSet(); for (String name : where.keySet()) { if (where.get(name).contains(place)) { names.add(name); } } return names; } 4. before after code -----------------------+-----------------------+------------------------------- p->[1]->[2] | p-> | p.next.next = q; | | q = p; q->[3] | q->[1]->[2]->[3] | p = null; -----------------------+-----------------------+------------------------------- p->[1]->[2]->[3] | p->[1]->[3] | q = p.next; | | p.next = p.next.next; q | q->[2] | q.next = null; -----------------------+-----------------------+------------------------------- p->[1]->[2] | p->[2]->[3] | ListNode temp = p.next; | | temp.next.next = q; q->[3]->[4] | q->[1]->[4] | q.next.next = p; | | p.next = null; | | p = q.next; | | -----------------------+-----------------------+------------------------------- p->[1]->[2]->[3] | p->[5]->[1] | ListNode temp = p.next; | | temp.next.next = q; | | q.next.next = p; q->[4]->[5] | q->[2]->[3]->[4] | p.next = null; | | p = q.next; | | q.next = null; | | q = temp | | -----------------------+-----------------------+------------------------------- 5. public static int removeMin(Stack s) { Queue q = new LinkedList(); int min = s.pop(); q.add(min); while (!s.isEmpty()) { int next = s.pop(); if (next < min) min = next; q.add(next); } while (!q.isEmpty()) { int next = q.remove(); if (next != min) s.push(next); } while (!s.isEmpty()) q.add(s.pop()); while (!q.isEmpty()) s.push(q.remove()); return min; } 6. public ArrayIntList reverseCopy() { ArrayIntList result = new ArrayIntList(elementData.length); for (int i = 0; i < size; i++) { result.elementData[i] = elementData[size - 1 - i]; } result.size = size; return result; }