Categorygithub.com/szhou12/leetcode-goleetcode0442-Find-All-Duplicates-in-an-Array
package
0.0.0-20241220224003-b7cf03a90b2b
Repository: https://github.com/szhou12/leetcode-go.git
Documentation: pkg.go.dev

# README

442. Find All Duplicates in an Array

Solution idea

思路与 448. Find All Numbers Disappeared in an Array 一致: 把元素与index关联起来, 出现一个元素,就在以它作为index的位置做标记 ($* -1$), 再遇到负数,就说明这个元素出现了两次,是我们要找的。

Time complexity = $O(n)$