Commit 441d454a authored by Mikkel Wienberg Madsen's avatar Mikkel Wienberg Madsen 👀
Browse files

Intersection Function

parent f221ee99
Pipeline #21715 failed with stages
in 14 seconds
......@@ -59,3 +59,19 @@ func (j *Judge) GoodIds() []uuid.UUID {
}
return good
}
func Intersection(superset [][]uuid.UUID) []uuid.UUID {
section := make(map[uuid.UUID]int, len(superset[0]))
for _, set := range superset {
for _, e := range set {
section[e]++
}
}
list := []uuid.UUID{}
for uuid, num := range section {
if num >= len(superset) {
list = append(list, uuid)
}
}
return list
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment