You are viewing a single comment's thread. Return to all comments →
Golang solution
func luckBalance(k int32, contests [][]int32) int32 { // Write your code here var sum_luck int32 var max_fail []int for i:=0; i<len(contests);i++{ if contests[i][1] == 0 { // fmt.Println(contests[i][0]) sum_luck += contests[i][0] } else { max_fail = append(max_fail, int(contests[i][0])) } } sort.Ints(max_fail) for i:=int32(0);i<int32(len(max_fail));i++{ if i<int32(len(max_fail))-k { sum_luck -= int32(max_fail[i]) } else { sum_luck += int32(max_fail[i]) } } return sum_luck }
Seems like cookies are disabled on this browser, please enable them to open this website
Luck Balance
You are viewing a single comment's thread. Return to all comments →
Golang solution