Adrian just hasn't thought far enough :-)
Loop through array 1 and 2 and add all sums to a map.
Now from the other 2 arrays find all combinations which add up to a number in the map which you got from array 1 and 2. It's pretty straight forward. Let me know if you need some pseudocode.
O(n^2) runtime
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With