Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Maximum sum subarray of size ‘K’

l=[4,6,10,8,2,1]
ans=0
m=3
for i in range(len(l)+1):
   for j in range(i):
       if len(l[j:i])==m:
          ans=max(ans,sum(l[j:i]))
print(ans) 

Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Maximum #sum #subarray #size
ADD COMMENT
Topic
Name
6+7 =