Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
and also contains() isn't necessary in this solution, since calling add() directly also tells you if the element is in the set or not.
Why a TreeSet? As contains will take O(logN) vs HashSet for O(1). I like your solution overall though and very neat ;)
Looks like you are using two for inner loops, which will end up with O(N^2) as brute-force solution. You need to improve the performance to at least O(N).