add minor optimization
solution without using Set
recursive solution
cleaner