20201110_find_lost_number

This commit is contained in:
VicRen
2020-11-10 14:29:29 +08:00
parent 37ac2b7c2b
commit b7f6c8451b
2 changed files with 17 additions and 2 deletions
+2 -2
View File
@@ -24,8 +24,8 @@ func findLostNumber(nums []int) int {
for _, n := range nums {
sum += n
}
n := len(nums)
return n*(n+1)/2 - sum
l := len(nums)
return l*(l+1)/2 - sum
}
func findLostNumber2(nums []int) int {