15 lines
328 B
Go
15 lines
328 B
Go
// Package q961 implements a solution for https://leetcode.com/problems/n-repeated-element-in-size-2n-array/
|
|
package q961
|
|
|
|
import "math/rand"
|
|
|
|
func repeatedNTimes(nums []int) int {
|
|
for {
|
|
a, b := rand.Intn(len(nums)), rand.Intn(len(nums))
|
|
if b != a && nums[a] == nums[b] {
|
|
return nums[a]
|
|
}
|
|
}
|
|
}
|
|
|
|
var _ = repeatedNTimes
|