This file contains hidden or 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 { | |
| output := make([][]int, numRows) | |
| if numRows >= 1 { | |
| output[0] = []int{1} | |
| } | |
| if numRows >= 2 { | |
| output[1] = []int{1, 1} | |
| } |
This file contains hidden or 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 min(a,b int) int { | |
| if a < b { | |
| return a | |
| } | |
| return b | |
| } | |
| func minCostClimbingStairs(cost []int) int { | |
| var first, second int |
This file contains hidden or 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 | |
| func climbStairs(n int) int { | |
| result := 0 | |
| firstPrev, secondPrev := 0, 0 | |
| for i := 1; i <= n; i++ { | |
| if i == 1 { | |
| result = 1 |