Set는 다른 Set와 비교하여 같은 값들만 다시 Set로 반환하는 intersection 메서드가 존재합니다

 

func solution(_ s1:[String], _ s2:[String]) -> Int {
    return Set(s1).intersection(Set(s2)).count
}

 

ytw_developer