4th Street Bar Hive-Bar

Hive-Bar Powered by Hive beta-fdb5b5b

Community post

HackerRank solutions - Compare the Triplets

favicon144.png

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.

// solution
function solve(a0, a1, a2, b0, b1, b2){
    // Complete this function
    var alices_points = ( a0 > b0 ? 1 : 0 ) + ( a1 > b1 ? 1 : 0 ) + ( a2 > b2 ? 1 : 0 );
    var bobs_points = ( a0 < b0 ? 1 : 0 ) + ( a1 < b1 ? 1 : 0 ) + ( a2 < b2 ? 1 : 0 );
    
    return [ alices_points, bobs_points ];
}

The return value confused me for a little bit. I thought I had to return the string '1 1' as the solution.
4 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: