Created
March 10, 2021 16:37
-
-
Save minhphong306/1b70e63c5c20fdcc2a4cbba06406b3d6 to your computer and use it in GitHub Desktop.
find_not_duplicate_number_sol1.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func solution1(arr []int) int { | |
mainLoop: | |
for i := 0; i < len(arr); i++ { | |
pivot := arr[i] | |
for j := 0; j < i; j++ { | |
if arr[j] == pivot { | |
continue mainLoop | |
} | |
} | |
for j := i + 1; j < len(arr); j++ { | |
if arr[j] == pivot { | |
continue mainLoop | |
} | |
} | |
return pivot | |
} | |
return -1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment