Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
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
Get started
Validate Deadline Eligibility Updates
00:00
5 left

Validate Deadline Eligibility Updates

MediumPython

Problem

Scale.ai task workflows may allow an annotator task to receive a later deadline, but only while the task remains eligible for modification. Implement update_deadline to validate all rules and return the updated task when the change is allowed.

A task is eligible only when:

  1. Its status is exactly "pending".
  2. The current time is strictly before its existing deadline.
  3. The current time is no more than modification_window seconds after created_at.
  4. The proposed new_deadline is strictly later than both the current time and the existing deadline.
  5. The proposed deadline does not exceed created_at + max_lifetime.

If every rule passes, return a copy of the task with its deadline replaced by new_deadline. Otherwise, return None. Do not modify the input dictionary when the update is rejected.

Formal Specification

Input is a dictionary containing integer Unix timestamps for created_at, deadline, modification_window, and max_lifetime, plus a string status. The function also receives integer new_deadline and now values. Return a dictionary on success or None on failure.

Constraints

  • Timestamps are integers from 0 through 10^9.
  • 0 <= created_at < deadline <= created_at + max_lifetime.
  • 1 <= modification_window, max_lifetime <= 10^9.
  • status is a non-empty string.
  • The input task dictionary contains all required keys.

Function Signature

def update_deadline(task, new_deadline, now):
Interviewer

Your question is Validate Deadline Eligibility Updates. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
Code
Sign up free to run your codeLog inLn 2
Run your code to see test output here.