Sort 3 Discussions, By:
Please Login in order to post a comment
That's weird ... I wrote a valid algorithm to check a set but it's O(n^2) and just too slow to verify a big set. Therefore I added a shortcut: always return "NO" whenever a set has 30+ elements. I got a final score of 100% :-)
Well, the range of values of a set of 2 elements is 2*10^6 and there are n*(n-1)/2 sets of 2 elements; it takes a little over 1000 to exceed the range. If every subset has a distinct value, than there are 2^n-1 distinct values or at least 2^30-1, in your case. That's larger than the range of any subset, which is n <= range <= n*10^6.
Can t seem to be able to pass test 14.
all sets are 20 max elements.
Updated: Counter over defaultdict, seem to pass.
Good luck who you come after.
Am I right to think that subsets of length 1 (singletons) are not taken into account ?
Constraints: 1≤n≤100. Apparently, set of size 1 is a valid set.
No more comments