897. Sum of Array Elements II

Given an array nums, find the sum of elements of array using recursion.

Example 1:

Input : nums = [1, 2, 3]

Output : 6

Explanation : The sum of elements of array is 1 + 2 + 3 => 6.

Example 2:

Input : nums = [5, 8, 1]

Output : 14

Explanation : The sum of elements of array is 5 + 8 + 1 => 14.

Now Your Turn!

Pick the correct output for the given input

Input : nums = [12, 9, 17]

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 1 <= n <= 100
  • 0 <= nums[i] <= 100
0
class Solution{
public:
int arraySum(vector<int>& nums){
//your code goes here
}
};
Test Case

Input:

Nums