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.
Project Euler #201: Subsets with a unique sum
Project Euler #201: Subsets with a unique sum
Sort by
recency
|
28 Discussions
|
Please Login in order to post a comment
why sum=15 (8+1+6) is not included in the unique sums set (in the example)?
Please find error in the code c#
using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static void Main(String[] args) {
}
Cannot contain duplicate??... Maybe
I simplified the code.but stil showing timeout error for few test cases.anybody have an idea?
from itertools import combinations sm_r=set() sm_l=set() start=list(map(int,input().split())) n,m=start[0],start[1] array=list(map(int,input().split())) c_l=list(combinations(array,m))
for pair in c_l: sm=sum(list(pair)) if sm not in sm_l: sm_l.add(sm) else: sm_r.add(sm) print(sum(sm_l.difference(sm_r)))
My solution ablr to pass only 6 test case how i can optimize this :