Skip to main content

217. Contains Duplicate

分析


题解

space: n time: n

function containsDuplicate(nums: number[]): boolean {
const memo = {}
for (const num of nums) {
if (memo[num]) {
return true
}
memo[num] = true
}
return false
};