- 1
Pls sove this in JavaScript
Write a function that would sum up pairs of numbers and print all pairs that equal to 5? Part 2 - Can you write the same program with just a single loop – var arr = []; arr[0] = [1, 2, 3, 4, 5, 6, 7, -2, 0, -1, ]; function SumOfPairs (numbersWithDuplicates) { //Write your code here } SumOfPairs (arr) //Example 2+3 =5 1+4 = 5 Question 3
1 Antwort
+ 3
There are many ways to do it in single loop you can sort and then ise two pointers to find sum or you can store frequency of previous elements and check if current element has its complement in that frequency array