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" | |
func main() { | |
fmt.Println(missingNumber([]int{3,0,1})) | |
} | |
func missingNumber(nums []int) int { | |
m := make(map[int]struct{}, len(nums)) |
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
var memo map[int]int | |
func init(){ | |
memo = make(map[int]int) | |
memo[1] = 1 | |
memo[2] = 2 | |
} | |
func climbStairs(n int) int { | |
if v, ok := memo[n]; ok { | |
return v |
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
func generate(numRows int) [][]int { | |
ret := make([][]int, numRows) | |
for i := 1; i <= numRows; i++ { | |
ret[i-1] = make([]int, i) | |
ret[i-1][0], ret[i-1][i-1] = 1, 1 | |
for j := 2; j < i && j <= numRows-1; j++ { | |
ret[i-1][j-1] = ret[i-2][j-2] + ret[i-2][j-1] | |
} | |
} | |
return ret |
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
type List(type T) []T | |
func (l *List(T)) Filter(func(T) bool) *List(T) | |
func (l *List(T)) Map(func(T) T) *List(T) | |
func main(){ | |
var l List{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10} | |
l.Filter(func(i int) bool { |
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" | |
"github.com/kr/pretty" | |
) | |
type IntList []int |
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
version: 2 | |
jobs: | |
build: | |
working_directory: /go/src/github.com/your_company/your_app | |
docker: | |
- image: circleci/golang:1.10.0 | |
environment: | |
- GOCACHE: "/tmp/go/cache" | |
steps: |
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
version: 2 | |
jobs: | |
build: | |
working_directory: /go/src/github.com/your_company/your_app | |
docker: | |
- image: circleci/golang:1.10.0 | |
environment: | |
- DEP_VERSION: 0.4.1 | |
steps: | |
- run: git config --global url.ssh://[email protected]/your_company.insteadOf https://github.com/your_company |
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
version: 2 | |
jobs: | |
build: | |
working_directory: /go/src/github.com/your_company/your_app | |
docker: | |
- image: circleci/golang:1.10.0 | |
environment: | |
- GOCACHE: "/tmp/go/cache" | |
- DEP_VERSION: 0.4.1 | |
steps: |
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 design // The convention consists of naming the design | |
// package "design" | |
import ( | |
. "github.com/goadesign/goa/design" // Use . imports to enable the DSL | |
. "github.com/goadesign/goa/design/apidsl" | |
) | |
var _ = API("cellar", func() { // API defines the microservice endpoint and | |
Title("The virtual wine cellar") // other global properties. There should be one | |
Description("A simple goa service") // and exactly one API definition appearing in |
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 ( | |
"reflect" | |
"testing" | |
) | |
func BenchmarkSetIntMap(b *testing.B) { | |
m := make(map[int]bool) | |
for i := 0; i < b.N; i++ { |
NewerOlder