You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
publicfunc checkIfExist(_ arr:[Int])->Bool{guard !arr.isEmpty else{returnfalse}varset:Set<Int>=[]foriin0..<arr.count {if set.contains(arr[i]*2) || (arr[i]%2==0 && set.contains(arr[i]/2)){
// If either the double or half of the current element exists in the set, return true
returntrue}
set.insert(arr[i])}
// for i in 0..<arr.count {
// let num = 2*arr[i]
// results.insert(num)
// }
// for value in arr {
// if results.contains(value) {
// return true
// }
// }
returnfalse}
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: