HackerRank solutions - Compare the Triplets

in #hackerrank7 years ago (edited)

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.

Sort:  

Just taking this opportunity to say "THANK YOU FOR FOLLOWING ME"

Congratulations @brucelim! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Coin Marketplace

STEEM 0.17
TRX 0.16
JST 0.028
BTC 76338.99
ETH 2965.83
USDT 1.00
SBD 2.62