题解 | #数组中重复的数字#
数组中重复的数字
https://www.nowcoder.com/practice/6fe361ede7e54db1b84adc81d09d8524
export function duplicate(numbers: number[]): number { // write code here const numberSet = new Set() for (let i = 0; i < numbers.length;i++) { if (numberSet.has(numbers[i])) return numbers[i] numberSet.add(numbers[i]) } return -1 }