+2.
+1.
+1. This version uses HashSet to avoid repeating generations. Needs better algorithm or understanding how to implement HashSet.