Solving HackerRank Problem: Compare the Triplets using both java and C sharp


Alice and Bob each created one problem for HackerRank. A reviewer rates the two challenges, awarding points on a scale from 1 to 100 for three categories: problem clarity, originality, and difficulty....Complete the function compareTriplets in the editor below


See the full details of the problem Compare the Triplets


  1. Let Alice's triple score be a0,a1,a2.
  2. Let Bob's triple score be b0,b1,b2.
  3. Let Alice's and Bob's total rating points be ta and tb respectively. Set ta and tb to 0.
  4. If a0 > b0 then ta by 1.
  5. If b0 > a0 then tb by 1.
  6. If a1 > b1 then ta by 1.
  7. If b1 > a1 then tb by 1.
  8. If a2 > b2 then ta by 1.
  9. If b2 > a2 then tb by 1.
  10. Print ta and tb on console separated by space.

Time Complexity: O(1) //There are no iteration loops in the algorithm steps.

Space Complexity: O(1) //number of dynamically allocated variables remain constant for any input.