Skip to content

Instantly share code, notes, and snippets.

@rphuber
Created April 14, 2024 02:09
Show Gist options
  • Save rphuber/060c9f1a11e7dde4baffa7574e82716c to your computer and use it in GitHub Desktop.
Save rphuber/060c9f1a11e7dde4baffa7574e82716c to your computer and use it in GitHub Desktop.
func linearSearch(slice []int, target int) (index, numTests int) {
for idx, val := range slice {
if val == target {
return idx, idx + 1
}
}
return -1, len(slice)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment