Untitled

mail@pastecode.io avatar
unknown
python
a month ago
557 B
1
Indexable
Never
def solution(firstArray, secondArray, target):
  count = 0
  
  for i in range(len(firstArray)):
    first_sum = 0
    for j in range(i, len(firstArray)):
      first_sum += firstArray[j]
      if first_sum > target:
        break
        
      for k in range(len(secondArray)):
        second_sum = 0
        for l in range(k, len(secondArray)):
          second_sum += secondArray[l]
          if first_sum + second_sum == target:
            count += 1
          if second_sum > target:
            break
              
  return count
Leave a Comment