Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Start free
HackerRank Candidate Solved Questions and Runtime
00:00
5 left

HackerRank Candidate Solved Questions and Runtime

MediumSQL · PostgreSQL

Problem

How would you handle three coding questions on HackerRank where you have to use Python?

For the SQL version, use the supplied HackerRank assessment tables to summarize candidates who attempted all three required questions. Include candidates even when some submissions failed, and treat multiple submissions to the same question as one attempted question.

Output

  1. One row per candidate who attempted all three required questions.
  2. Return candidate_name, attempted_questions, solved_questions, and average_passed_runtime_ms.
  3. Sort by solved_questions descending, average passed runtime descending with NULL values last, then candidate_id ascending.

Output details

  • Treat the required questions as question numbers 1, 2, and 3.
  • Count a question as solved when at least one submission has status Passed.
  • Calculate the average from all Passed submissions' runtime values, returning NULL when none exist.
  • Round average_passed_runtime_ms to two decimal places, preserving trailing zeroes.

Schema

candidates
ColumnTypeDescription
candidate_idPKINTUnique candidate identifier
candidate_nameVARCHAR(100)Candidate display name
emailVARCHAR(150)Candidate email address
questions
ColumnTypeDescription
question_idPKINTUnique question identifier
question_numberINTQuestion position in the assessment
titleVARCHAR(150)Question title
submissions
ColumnTypeDescription
submission_idPKINTUnique submission identifier
candidate_idINTCandidate who submitted the solution
question_idINTQuestion being answered
statusVARCHAR(20)Submission result, such as Passed or Failed
runtime_msINTExecution runtime in milliseconds
Tablescandidatesquestionssubmissions
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the three tables are in the Question tab.

Sign up free to run or submit. Log in
CodePostgreSQL
Sign up free to run your code. Your draft is saved.Run with a free accountLog inLn 1
Run your query to see results here.