Skip to content

Commit

Permalink
Merge pull request #169 from Vishal19111999/master
Browse files Browse the repository at this point in the history
added linear search in golang
  • Loading branch information
ankiiitraj authored Oct 7, 2020
2 parents cbf1b2e + a97432c commit 5452e51
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions linear_search/linear_search.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package main

import "fmt"

func linear_search (size int, key int, arr []int) string{

for i := 0; i < size; i++ {
if arr[i]==key{
return "found"
}
}

return "not found"

}

func main() {

arr := []int{1, 2, 3, 4, 5}
ans := linear_search(5,2,arr)
fmt.Println(ans)

}

0 comments on commit 5452e51

Please sign in to comment.