Skip to content
Advertisement

How can I return a sorted list of integers here? [closed]

JavaScript

My problem is on the last line. In the last line, I wanted to return 4, 8, 9, 10 but it’s only returning 10 instead. Where should I put the sort operation? I tried assigning first, it worked, but only on the assigned value and not whatever the test case would use.

Advertisement

Answer

I used a set to track pair elements and sorted the resulting list.

Program:

JavaScript

Result:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement