Compare the Triplets

Sort by

recency

|

4295 Discussions

|

  • + 0 comments

    Hi this is my JS solution

    function compareTriplets(a, b) {
    
    if (a.length <=0 || b.length <=0) return 0;
    
    let alice=[0,0]; 
    
    for(let i = 0; i<a.length; i++){
        if(a[i] > b[i]) {
            alice[0]++;
        } else if(b[i]>a[i]){
            alice[1]++;
        }
    }
    return alice;
    
    }
    
  • + 1 comment

    Does anyone know what this is supposed to mean?

    For elements 0, Bob is awarded a point because a[0] .

    "Because a[0]"?

  • + 0 comments

    Does anyone know the answer for C programming language

  • + 0 comments

    Here is my c++ solution, you can watch the explanation here: https://youtu.be/aI9vQg2gO0Q

    #include <bits/stdc++.h>
    
    using namespace std;
    
    int main() {
        int a1, a2, a3, alicePoint = 0, b1, b2, b3, bobPoint = 0;
        cin >> a1 >> a2 >> a3;
        cin >> b1 >> b2 >> b3;
        alicePoint = ((a1 > b1? 1:0)) + ((a2 > b2? 1:0)) + ((a3 > b3? 1:0));
        bobPoint = ((a1 < b1? 1:0)) + ((a2 < b2? 1:0)) + ((a3 < b3? 1:0));
        cout << alicePoint << " " << bobPoint ;
        return 0;
    }
    
  • + 0 comments

    Hello, I'm new here and beginer of coding course.

    Always appreciate your assistance while using coding practice in my site https://yowsap.com/