Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func testPhoneNumbers(_ numbers: [String]) -> Bool {
- var tmp = numbers
- while !tmp.isEmpty {
- let numberToTest = tmp.removeFirst()
- if !tmp.allSatisfy({ !$0.hasPrefix(numberToTest) }) {
- return false
- }
- }
- return true
- }
- let testCount = Int(readLine()!)!
- for _ in 1...testCount {
- let phoneNumberCount = Int(readLine()!)!
- var phoneNumbers = [String]()
- for _ in 1...phoneNumberCount {
- phoneNumbers.append(readLine()!)
- }
- phoneNumbers.sort()
- print(testPhoneNumbers(phoneNumbers) ? "YES" : "NO")
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement