Solution for MySql by Danniel

  • 0

    This solution works in MySQL, please pray for my interview tomorrow :)

    select S2.Score as Score, cast(S3.Rank as UNSIGNED) as Rank
    from Scores S2
    left join (
    select S.Score as Score,
    @curRank := @curRank+ 1 as Rank
    from (select distinct Score from Scores) S, (select @curRank := 0 ) R
    order by S.Score desc
    ) S3
    on S2.Score = S3.Score
    order by S3.Rank asc

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.