Created
February 14, 2016 21:25
-
-
Save gleicon/8d1001d1a8a745a6d2c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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