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.
This works for the test case but runs out of time in other cases.
I am seeing overly complicated solutions and not many of those.
The solution cannot be so complicated.
defking(army,k):# Write your code hereways=20countries=kdetachments=0ifnotlen(army)>0:return0ifnotk>0:return0forindex,soldiersinenumerate(army):forxinrange(index+1,len(army)):# combinationsdetachments1=math.comb(soldiers,4)+1detachments2=math.comb(army[x],4)+1detachments+=detachments1*detachments2return(int(detachments%(10E9+7)))
King and Four Sons
You are viewing a single comment's thread. Return to all comments →
This works for the test case but runs out of time in other cases. I am seeing overly complicated solutions and not many of those. The solution cannot be so complicated.