- Prepare
- Algorithms
- Warmup
- Simple Array Sum
- Discussions
Simple Array Sum
Simple Array Sum
+ 0 comments This code written is Js is working in vs code but in hackerrank it is showing undefined can anyone help me out...
let sum = 0; for (let i = 0; i < ar.length; i++) { // console.log(ar[i]); sum = sum + ar[i] } console.log(sum)
+ 0 comments Here is my solution for the simpleArraySum function, you can see the video here : https://youtu.be/b7KAvErmVIw
int simpleArraySum(vector<int> ar) { int sum = 0; for(int i = 0; i < ar.size(); i++){ sum += ar[i]; } return sum; }
+ 0 comments Here is the solution of Simple Array sum @OGAdultWebSeries">
+ 0 comments function simpleArraySum(ar) { let sum=0; console.log(ar.length); for(let i=0 ;i< ar.length; i++){ sum=sum + ar[i]; } return sum;
}
+ 0 comments Here is my code:
`def simple_array_sum(arr): """ Calculates the sum of elements in an array.
Parameters: arr (list): The input array of numbers. Returns: int: The sum of elements in the array. """ return sum(arr)
array = [1, 2, 3, 4, 5] sum_of_array = simple_array_sum(array) print("Sum of the array:", sum_of_array)
`
Sort 3161 Discussions, By:
Please Login in order to post a comment