Three Arrays!

Published by Mubashir Hassan in

Given three arrays of integers: arr1, arr2, arr3, return the sum of integers which are common in all three arrays.

Examples

sum_common([1, 2, 3], [5, 3, 2], [7, 3, 2]) ➞ 5
// 2 & 3 are common in all 3 arrays.

sum_common([1, 2, 2, 3], [5, 3, 2, 2], [7, 3, 2, 2]) ➞ 7
// 2, 2 & 3 are common in all 3 arrays.

sum_common([1], [1], [2]) ➞ 0

Notes

N/A

Watch a quick demo on how Edabit works.