Answers for "sum of subarray in python"

0

sum of subarray in python

def SubArraySum(arr, n):
  n = len(arr)
  temp,result = 0,0
  # Pick starting point
  for i in range(0, n):
    # Pick ending point
        temp=0;
       for j in range(i, n):
         # sum subarray between
         # current starting and
         # ending points
          temp+=arr[j]
          result += temp
    return result
Posted by: Guest on August-16-2021

Python Answers by Framework

Browse Popular Code Answers by Language