leetcode-2176
题目
分析
- 找值相同,且下标可以被k整除的数对数量
- 暴力循环,一个一个找O(n2)
- 哈希记录,每个哈希记录里找匹配的数对(key为值,value为下标数组)
- 最差O(n2),所有数的值都一样的时候,考虑gcd算法优化?
源代码
https://github.com/Norton-Lin/algorithm/blob/master/go/src/leetcode_2176/2025_04_17_2176.go
https://github.com/Norton-Lin/algorithm/blob/master/go/src/leetcode_2176/2025_04_17_2176.go