• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

Compare the Triplets: printing two values

Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am solving a problem on hackerrank(https://www.hackerrank.com/challenges/compare-the-triplets/problem?h_r=next-challenge&h_v=zen). The problem states to complete the function
compareTriplets which must return an array of two integers, the first being ALice's score and the secoond being Bob's.

compareTriplets has the following parameter(s):

a: an array of integers representing Alice's challenge rating
b: an array of integers representing Bob's challenge rating

For more detail on the problem, refer to the following link:

For the same challenge i wrote the following solution:

The problem states that the output should be like [1,1] i.e. [points earned by alice, points earned by bob]

But somehow it displays a array with four elements with the values [1], [], [1], []
Refer to https://ibb.co/GCkwM9j for further details.

Can anybody suggest anything?
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
Free, earth friendly heat - from the CodeRanch trailboss
    Bookmark Topic Watch Topic
  • New Topic