You are viewing a single comment's thread. Return to all comments →
Cool kid solution, have fun with it!
cum = [] l = {} def rec(i,j): m = cum[i-1]+((cum[j]-cum[i-1])/2) return 0 if m not in l else 1+max(rec(i,l[m]),rec(l[m]+1,j)) def arraySplitting(arr): global cum, l cum = list(accumulate(arr)) + [0] l = {cum[i]:i for i in range(len(cum)-1)} # lookup return len(arr)-1 if cum[-2]==0 else rec(0,len(arr)-1)
Using accumulate() from itertools
Seems like cookies are disabled on this browser, please enable them to open this website
Nikita and the Game
You are viewing a single comment's thread. Return to all comments →
10 lines in Python, 100%
Cool kid solution, have fun with it!
Using accumulate() from itertools