We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
原题链接
排序后看相邻两位的数字
const containsDuplicate = function(nums) { nums.sort((a, b) => a - b) const n = nums.length for (let i = 0; i < n - 1; i++) { if (nums[i] === nums[i + 1]) { return true } } return false }
const containsDuplicate = function(nums) { const set = new Set() for (const x of nums) { if (set.has(x)) { return true } set.add(x) } return false }
const containsDuplicate = function(nums) { return new Set(nums).size !== nums.length }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
原题链接
排序
排序后看相邻两位的数字
哈希表
一行代码
The text was updated successfully, but these errors were encountered: