Skip to content

Latest commit

 

History

History

11-MultiDimensionalSumArray

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Multi-Dimensional SumArray

Introduction

We already work with one-dimensional arrays, now we will go up a notch and go through two-dimensional arrays, that is, an array of integer arrays.

In this case, the goal is to find the sum of all the elements of the array.

Example

arr=[1,2,3,4]

output: 10

arr=[ [2,4] , [1], [4,2,1] ]

output: 14

Function Description

md_array_sum has the following paramter(s):

arr[n]: an array of integers

Returns

int: sum total

Sample Input

[ 2, [3,4], 5, [-3, [6 , [ 4,5 ] ] ] ]

Sample Output

26