News

Method 1 : Using Iteration Method 2 : Using recursion (Top-Down Approach) Method 3 : Using recursion (Bottom-up Approach) Method 1 : Create a variable say sum = 0. Run a loop to iterate over the ...
Example 2: Input: N = 3 Arr [] = {1, 3, 3} Output: 7 Explanation: 1 + 3 + 3 = 7. Your Task: Complete the function sum () which takes array arr and single integer n, as input parameters and returns an ...