luoheng
10/6/2019 - 7:38 AM

arraysIntersection

func arraysIntersection(arr1 []int, arr2 []int, arr3 []int) []int {
    sum := [2001]int{}
    length := len(arr1)
    for i := 0; i < length; i++ {
        sum[arr1[i]]++
    }
    length = len(arr2)
    for i := 0; i < length; i++ {
        sum[arr2[i]]++
    }
    length = len(arr3)
    for i := 0; i < length; i++ {
        sum[arr3[i]]++
    }
    result := make([]int, 0, 4)
    for i := 1; i < 2001; i++ {
        if sum[i] == 3 {
            result = append(result, i)
        }
    }
    return result
}