Contest Leaderboard

Sort by

recency

|

2167 Discussions

|

  • + 0 comments

    WITH max_score_per_challenge AS ( SELECT hacker_id, challenge_id, MAX(score) AS maxscore FROM submissions GROUP BY hacker_id, challenge_id ),

    total_score AS ( SELECT hacker_id, SUM(maxscore) AS sumscore FROM max_score_per_challenge GROUP BY hacker_id )

    SELECT h.hacker_id, h.name, t.sumscore FROM Hackers as h JOIN total_score as t ON h.hacker_id = t.hacker_id WHERE t.sumscore > 0 ORDER BY t.sumscore DESC, h.hacker_id ASC

  • + 0 comments

    with max_scores as ( select s.hacker_id, h.name, max(s.score) as max_scores from submissions s inner join hackers h on s.hacker_id = h.hacker_id group by s.hacker_id, h.name, s.challenge_id) select hacker_id, name, sum(max_scores) from max_scores group by hacker_id, name having sum(max_scores) > 0 order by 3 desc, 1 asc;

  • + 0 comments

    ATTENTION! BUG FOUND! Apparently this particular problem environment isn't supporting CTEs and cites the WITH clause as an 1064 error. Either HackerRank needs to debug this or clarify in the problem description that the intent is to demonstrate achieving the same result without the explicit use of a CTE.

  • + 0 comments
    select hackers.hacker_id
    , name
    , sum(score) total_score
    from hackers
    inner join (
                select hacker_id, max(score) as score
                from submissions
                group by hacker_id, challenge_id) as submissions on hackers.hacker_id = submissions.hacker_id
    group by hackers.hacker_id, name
    HAVING SUM(score) > 0
    order by sum(score) desc, hacker_id
    
  • + 0 comments

    /* MY SQL */

    select a.hacker_id ,a.name ,sum(a.score) from ( select h.hacker_id ,h.name ,s.challenge_id ,MAX(s.score) as score from Hackers h join Submissions s on h.hacker_id = s.hacker_id group by h.hacker_id ,h.name ,s.challenge_id ) a

    group by a.hacker_id ,a.name

    HAVING sum(a.score) > 1

    order by sum(a.score) desc , a.hacker_id