Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package main
import "fmt"
func main() {
lg, positions := largestNumber([]int{71, 114, 105, 109, 84, 104, 101, 82, 101, 97, 112, 101, 114})
fmt.Printf("Largest Number: %v\n", lg)
fmt.Print("Positions: ")
for _, v := range positions {
fmt.Printf("%v ", v)
}
fmt.Println()
}
func largestNumber(na []int) (lg int, positions []int) {
for i, v := range na {
if v == lg {
positions = append(positions, i)
}
if v > lg {
lg = v
positions = []int{i}
}
}
return
}
@GrimTheReaper

This comment has been minimized.

Copy link
Owner Author

GrimTheReaper commented Dec 23, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.