Skip to content

Instantly share code, notes, and snippets.

@gleicon
Created February 14, 2016 21:25
Show Gist options
  • Save gleicon/8d1001d1a8a745a6d2c4 to your computer and use it in GitHub Desktop.
Save gleicon/8d1001d1a8a745a6d2c4 to your computer and use it in GitHub Desktop.
package main
import "fmt"
// this is the intro to tutorial challenges from hackerrang in Go.
func findArrElement(arr []uint64, arrLen, value int) int {
for i:=0; i < arrLen; i++ {
if arr[i] == uint64(value) {
return i
}
}
return -1
}
func main() {
//Enter your code here. Read input from STDIN. Print output to STDOUT
var value, arrLen int
fmt.Scan(&value, &arrLen)
arr := make([]uint64, arrLen)
for i:= 0; i < arrLen; i ++ {
fmt.Scan(&arr[i])
}
ret := findArrElement(arr, arrLen, value)
fmt.Println(ret)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment