Oct 30, 2024
I wonder if you considered using NSCountedSet (https://developer.apple.com/documentation/foundation/nscountedset). something like:
import Foundation
let set0 = NSCountedSet(array: "AAATTCGAATGGTATGCC".split(separator: ""))
let set1 = NSCountedSet(array: "TTAACAGAAGTCCGGTAT".split(separator: ""))
print(set0 == set1)
Sadly Apple's documentation doesn't give time complexities for NSCountedSet, the string splitting has O(n), similar to your code.