1346. Check If N and Its Double Exist
🟩 Easy
Solution
My Solution
func checkIfExist(arr []int) bool {
m := make(map[int]bool, len(arr))
for _, num := range arr {
if _, ok := m[num*2]; ok || (num%2 == 0 && m[num/2]) {
return true
}
m[num] = true
}
return false
}

Leetcode: link
Last updated
Was this helpful?