You are viewing a single comment's thread. Return to all comments →
this is my go solution, some extra lines maybe buy very good performance.
cleanRanked := func(ranked []int32) []int32 { newRank := make([]int32, 0) for i := 0; i < len(ranked)-1; i++ { if ranked[i] != ranked[i+1] { newRank = append(newRank, ranked[i]) } } newRank = append(newRank, ranked[len(ranked)-1]) return newRank }(ranked) j := 0 var position int32 = 1 positions := make([]int32, len(player)) for i := len(player) - 1; i >= 0; i-- { for j <= len(cleanRanked)-1 && cleanRanked[j] > player[i] { if j == len(cleanRanked)-1 || cleanRanked[j] > cleanRanked[j+1] { position++ } j++ } positions[i] = position } return positions }
Seems like cookies are disabled on this browser, please enable them to open this website
Climbing the Leaderboard
You are viewing a single comment's thread. Return to all comments →
this is my go solution, some extra lines maybe buy very good performance.