re: Daily Coding Puzzles - Nov 4th - Nov 9th VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Wednesday Array.diff (6 KYU): Your goal in this kata is to implement a difference function, which subtracts one list from another and returns th...
 

Go

func Difference(a []int, b []int) (diff []int) {
    m := make(map[int]bool)

    for _, item := range b {
        m[item] = true
    }

    for _, item := range a {
        if _, presence := m[item]; !presence {
            diff = append(diff, item)
        }
    }
    return
}
code of conduct - report abuse