We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Algorithms
  3. Warmup
  4. Simple Array Sum
  5. Discussions

Simple Array Sum

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 3161 Discussions, By:

recency

Please Login in order to post a comment

  • kaush2474
    2 days ago+ 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|
    Permalink
  • alban_tyrex
    3 days ago+ 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|
    Permalink
  • dream101221
    3 days ago+ 0 comments

    Here is the solution of Simple Array sum @OGAdultWebSeries">

    -1|
    Permalink
  • denizdagli
    4 days ago+ 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|
    Permalink
  • henryrichards191
    5 days ago+ 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)

    `

    0|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy