MCPcopy Create free account
hub / github.com/VanjaRo/LeetCode / missingNumber

Function missingNumber

tasks/268.go:7–14  ·  view source on GitHub ↗
(nums []int)

Source from the content-addressed store, hash-verified

5}
6
7func missingNumber(nums []int) int {
8 n := len(nums)
9 sum := int(float32(1+n) / float32(2) * float32(n))
10 for _, el := range nums {
11 sum -= el
12 }
13 return sum
14}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected