func solution(arr:[Int])->Int{
var dup:Int = -1
for i in arr{
let dupInt:[Int] = arr.filter{ $0 == i }
if dupInt.count > 1 {
dup = i
break
}
}
return dup
}
func solution(arr:[Int])->Int{
var dup:Int = -1
for i in arr{
let dupInt:[Int] = arr.filter{ $0 == i }
if dupInt.count > 1 {
dup = i
break
}
}
return dup
}
本文标题:[Codility] Duplicate Item in arr
本文链接:https://www.haomeiwen.com/subject/svnujttx.html
网友评论