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.
- Prepare
- Algorithms
- Warmup
- Compare the Triplets
- Discussions
Compare the Triplets
Compare the Triplets
+ 0 comments hi all could someone spot the logic mistake in my code??
int* compareTriplets(int a_count, int* a, int b_count, int* b, int* result_count) { result_count[0]=0; result_count[1]=0; for(int i = 0;i <= a_count;++i) { if(a[i]>b[i]) //6>5 { result_count[0]++; } else if(a[i]<b[i]) //7<10 { result_count[1]++; } } return result_count; }
+ 0 comments def compareTriplets(a, b): # Write your code here score = [0, 0]
for i, j in zip(a, b): if i > j: score[0] += 1 elif i < j: score[1] += 1 return score
+ 0 comments Here is my simple Javascript (vanilla) solution
function compareTriplets(a, b) { let point = [0,0]; for (let i=0; i<a.length; i++) { if (a[i] > b[i]) { point[0] +=1; } else if (a[i] < b[i]) { point[1] +=1; } } return point }
+ 0 comments function compareTriplets(a, b) { let aScore=0; let bScore=0; for(let i=0 ;i<3;i++){ if(a[i]>b[i]) { aScore++ } else if(a[i]
return [aScore,bScore]; }
+ 0 comments def compareTriplets(a, b): alice = 0 bob = 0 i = 0 while i < 3: #Because only 3 metrics use for scaling if a[i] > b[i]: alice +=1 elif a[i] < b[i]: bob += 1 return [alice, bob]
i+=1 return [alice, bob]
Load more conversations
Sort 3918 Discussions, By:
Please Login in order to post a comment