Hackerrank: Compare the Triplets Solution

Implementation

1function compareTriplets(a, b) {
2 let [aPoint, bPoint] = [0, 0]
3
4 function compareAiBi(ai, bi) {
5 if (ai > bi) return aPoint++
6 if (bi > ai) return bPoint++
7 }
8
9 for (let i = 0; i < 3; i++) compareAiBi(a[i], b[i])
10
11 return [aPoint, bPoint]
12}

References

Original problem

Comments

Loading comments...

Tags

hackerrank

array

Next Post

LeetCode: Spiral Matrix II

Same with I, with a small modification

Previous Post

Hackerrank: Extra Long Factorials

Basically the multiply strings problem

HoningJS

Search Posts