We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #105: Special subset sums: testing
You are viewing a single comment's thread. Return to all comments →
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.