Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def electionsWinners(votes, k)
- maximum = votes.max
- array_length = votes.length
- x = 0
- winners = 0
- votes = votes.sort
- votes = votes.reverse
- if k == 0 then
- if votes[0] == votes[1] then
- return 0
- else
- return 1
- end
- end
- while (x < array_length)
- if votes[x] + k > maximum then
- winners = winners + 1
- end
- x = x + 1
- end
- return winners
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement