DataDrivenDataDriven
LearnPracticeInterviewDiscussDailyJobs

The Long Way Back

A hard SQL mock interview question on DataDriven. Practice with AI-powered feedback, real code execution, and a hire/no-hire decision.

Domain
SQL
Difficulty
hard
Seniority
L5

Interview Prompt

From our service health checks we track each service's monthly average uptime, and we want the services that slid downhill and then clawed their way back. Reading one service's months in time order, treat each unbroken run of consecutive falling months as a single decline stretch and each unbroken run of consecutive rising months as a single recovery stretch; a month whose average equals the one before it belongs to neither and ends whichever stretch was open. Match every decline stretch with each recovery stretch that starts after the decline stretch's final month, and for each pairing report the month each stretch began along with how far the service climbed: the highest monthly average anywhere in the recovery stretch minus the lowest anywhere in the decline stretch, over that lowest.

Summary

Some services fell apart and clawed their way back. Find them, and measure the climb.

How This Interview Works

  1. Read the vague prompt (just like a real interview)
  2. Ask clarifying questions to the AI interviewer
  3. Write your sql solution with real code execution
  4. Get instant feedback and a hire/no-hire decision

Related

  • All Mock Interviews
  • Practice Mode (untimed)
  • SQL Interview Questions
  • Data Engineering Interview Prep Guide
  • Practice Problems
  • Daily Challenge