4th Street Bar Hive-Bar

Hive-Bar Powered by Hive beta-fdb5b5b

Community post

HackerRank solutions - Simple Array Sum

Doing this so that I can document solutions for HackerRank for myself and discuss runtime complexities with other and try to come up with better solutions.

HackerRank - Simple Array Sum

// solution
function simpleArraySum(n, ar) {
    // Complete this function
    return ar.reduce( function( acc, val ) {
        return acc + val;
    } );
}

I think using the native js reduce function is simple solution without using for loops.

2 upvotes $0.00

Replies (2)

Review before signing

Posting as . Signing with . Keychain permission: Posting. Hive Keychain will ask you to approve this action next.


  
Technical details

Operation fingerprint: