Speed up Spectrum with use of HashSet