DEV Community

Discussion on: Daily Challenge #213 - Are they the "same"?

Collapse
 
kesprit profile image
kesprit

My Swift solution :

func comp(a: [Int], b: [Int]) -> Bool {
    guard !a.isEmpty, !b.isEmpty, a.count == b.count else { return false }

    return a.reduce(into: true) {
       $0 = b.contains($1 * $1)
    }
}