Skip to content

Instantly share code, notes, and snippets.

@HongzCloud
Created November 26, 2021 12:03
Show Gist options
  • Save HongzCloud/5838f198312d25afcbc6ad79da4b2229 to your computer and use it in GitHub Desktop.
Save HongzCloud/5838f198312d25afcbc6ad79da4b2229 to your computer and use it in GitHub Desktop.
PhoneNumberList_baekjoon
let repeatNum = Int(readLine()!)!
for i in 0..<repeatNum {
let testCount = Int(readLine()!)!
var answer = true
var numbers = [String]()
for j in 0..<testCount {
let number = readLine()!
numbers.append(number)
}
numbers.sort()
a: for i in 0..<numbers.count-1 {
if numbers[i + 1].hasPrefix(numbers[i]) {
answer = false
break a
}
}
answer == false ? print("NO") : print("YES")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment