go

LinearSearch Golang

vinaygo

vinay

Posted on September 6, 2022

LinearSearch Golang
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))

}

Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
vinaygo
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.

Related

Where GitOps Meets ClickOps
devops Where GitOps Meets ClickOps

November 29, 2024

How to Use KitOps with MLflow
beginners How to Use KitOps with MLflow

November 29, 2024