Use O(n) rather than O(n log n) algorithm.
Put into do to avoid vars leaking out.
Check containsFlush does the right thing for all combos.