Contest Leaderboard Answer

In the context of a coding challenge platform, hackers submit their solutions for various challenges. Each submission is scored based on its correctness and efficiency. The problem here is to calculate the total score for each hacker, considering only their highest score for each challenge.

Secure your next interview 🎯

CodeRankGPT is a tool powered by GPT-4 that quietly assists you during your coding interview, providing the solutions you need.
In real-time and absolutely undetectable 🥷

Here is the Contest Leaderboard Answer HackerRank solution using CodeRankGPT:

The solution approach involves two main steps. First, a subquery is used to select the maximum score for each hacker per challenge, ignoring challenges where the hacker scored zero. This is achieved using the MAX function, GROUP BY clause, and HAVING clause. Then, an inner join operation is performed to associate these scores with the corresponding hacker's details. The total score for each hacker is calculated using the SUM function, and the results are ordered by total score in descending order and hacker_id in ascending order.


SELECT h.hacker_id, h.name, SUM(MAX_SCORE.t1) as total_score
FROM Hackers h inner join 
(
    SELECT MAX(s.score) as t1, s.hacker_id  
    FROM Submissions s
    GROUP BY s.challenge_id, s.hacker_id
    HAVING t1 > 0
) AS MAX_SCORE
ON h.hacker_id = MAX_SCORE.hacker_id
GROUP BY h.hacker_id, h.name
ORDER BY total_score DESC, hacker_id ASC

If you have a HackerRank coding test coming up, you can use CodeRankGPT to your advantage. It will assist you during your interview and help ensure you get the job.

AI is here now, and other candidates might be using it to get ahead and win the job. 🧐

Built on Unicorn Platform