educative.io

The third answer in the quiz is confusing

The third answer in the quiz is confusing.

Question:
“What is the output if the following lists and value of k is given as input?
list 1 = [1, 5, 9, 14, 24, 27, 35]
list 2 = [1, 6, 8, 17, 30]
k = 15”

Answer:
“pairs = [[1, 1], [5, 1], [1, 6], [1, 8], [9, 1], [5, 6], [5, 8], [9, 6], [14, 1], [9, 8], [1, 17], [5, 17], [1, 30], [5, 30], [9, 30]]”

What about [14, 6] (= 20) and [14, 8] (= 22) that could come before [5, 17] (= 22)?

'What about [24, 1] (= 25) to be the last, after [5, 17] (= 22)?

This would be even a smaller set of num sums, wouldn’t it? Or am I missing some other constraint?


Course: Grokking Coding Interview Patterns in JavaScript - Learn Interactively
Lesson: Find K Pairs with Smallest Sums - Grokking Coding Interview Patterns in JavaScript


Course: Grokking Coding Interview Patterns in JavaScript - Learn Interactively
Lesson: Find K Pairs with Smallest Sums - Grokking Coding Interview Patterns in JavaScript

Hello @Elvin_Kosova,

Thank you for reporting this issue with the quiz. The correct output for this set of inputs would be “pairs = [[1, 1], [5, 1], [1, 6], [1, 8], [9, 1], [5, 6], [5, 8], [9, 6], [14, 1], [9, 8], [1, 17], [14, 6], [5, 17], [14, 8], [24, 1]]”, having all pairs of smallest sums.

The issue has been fixed, and I’ll let you know once the updated version goes live.

Regards,
Dian Us Suqlain
Developer Advocate @Educative.io

1 Like