Skip to content

Instantly share code, notes, and snippets.

@minhphong306
Created March 14, 2021 05:50
Show Gist options
  • Save minhphong306/55cfcdd5f9fbee388be266ab7705fc36 to your computer and use it in GitHub Desktop.
Save minhphong306/55cfcdd5f9fbee388be266ab7705fc36 to your computer and use it in GitHub Desktop.
sol3.go
func sol3(arr []int, n int) int {
sum := 0
for i := 0; i < len(arr); i++ {
sum += arr[i]
}
return sum - n*(n-1)/2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment