You are viewing a single comment's thread. Return to all comments →
Low constraints allow to check all possible sums.
def _indianJob(g, arr): s, sums = sum(arr), [1] + [0] * 10000 for i in arr: sums = sums[0:i] + [sums[x] or sums[x-i] for x in range(i,s+1)] return any([i<=g and s-i<=g for i in [i for i in range(s+1) if sums[i]]]) def indianJob(g, arr): return "YES" if _indianJob(g, arr) else "NO"
Seems like cookies are disabled on this browser, please enable them to open this website
The Indian Job
You are viewing a single comment's thread. Return to all comments →
4 line Python, 100%
Low constraints allow to check all possible sums.