Scala Programming: Find all combination of four elements of a given array whose sum is equal to a given value
Write a Scala program to find all combination of four elements of a given array whose sum is equal to a given value.
Sample Solution:
Scala Code:
Sample Output:
Original array: 10, 20, 30, 40, 1, 2, Given value: 53 Combination of four elements: 10 40 1 2 20 30 1 2
Scala Code Editor :
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Scala program to find the two elements from a given array of positive and negative numbers such that their sum is closest to zero.
Next: Write a Scala program to count the number of possible triangles from a given unsorted array of positive integers.
What is the difficulty level of this exercise?