LinearSearch Golang
vinay
Posted on September 6, 2022
package main
import (
"fmt"
"strconv"
)
func LinearSearch(a []int, k int) string {
i := 0
for i < len(a) {
if a[i] == k {
return "Found" + " index is " + strconv.Itoa(i)
}
i += 1
}
return "Not found index"
}
func main() {
a := []int{10, 20, 30, 40, 50}
fmt.Println(LinearSearch(a, 50))
}
💖 💪 🙅 🚩
vinay
Posted on September 6, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.