Skip to content

Instantly share code, notes, and snippets.

@krishna2nd
Created October 22, 2017 15:37
Show Gist options
  • Select an option

  • Save krishna2nd/67c9f8a3f48f16254aa82fd2bebb13e9 to your computer and use it in GitHub Desktop.

Select an option

Save krishna2nd/67c9f8a3f48f16254aa82fd2bebb13e9 to your computer and use it in GitHub Desktop.
package main;
import (
"fmt"
)
func main() {
var val = []int{ 1,2 ,3 ,4 ,115 ,6 ,17 ,8 ,9 };
var l1, l2 int = val[0], 0;
for _, v := range val {
if (l1 < v) {
l2 = l1
l1 = v
continue;
}
if (l2 < v && l2 < l1) {
l2 = v;
}
}
fmt.Println(l2)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment