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 | |
import ( | |
"fmt" | |
"sort" | |
) | |
type Slice []int | |
func (a Slice) Len() int { return len(a) } |
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
// Slice implements sort.Interface | |
type Slice []int | |
func (a Slice) Len() int { return len(a) } | |
func (a Slice) Swap(i, j int) { a[i], a[j] = a[j], a[i] } | |
func (a Slice) Less(i, j int) bool { return a[i] < a[j] } | |
func combine(n int, k int) [][]int { | |
a := []int{} | |
for i := 1; i <= n; i++ { |
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 findMaxConsecutiveOnes(nums []int) int { | |
total := 0 | |
max := 0 | |
for i := 0; i < len(nums); i++ { | |
if nums[i] == 1 { | |
total++ | |
if total > max { | |
max = total | |
} | |
} else { |
NewerOlder