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
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess 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
Build my plan
Reverse Integer Digits and Leap Year
00:00
5 left

Reverse Integer Digits and Leap Year

EasyPython

Problem

Keysight PathWave test automation may process numeric configuration values alongside calendar-based test metadata. Implement a function that reverses the digits of a signed integer and determines whether a given year is a leap year in the Gregorian calendar.

Formal Specification

Given integers number and year, return a dictionary with exactly two entries:

  • reversed: number with its decimal digits reversed. Preserve the sign, and discard leading zeroes in the reversed result.
  • is_leap_year: True if year is a leap year, otherwise False.

A year is a leap year if it is divisible by 400, or if it is divisible by 4 but not by 100. Use arithmetic rather than converting number to a string for the primary solution.

Constraints

  • -10^9 <= number <= 10^9
  • 1 <= year <= 9999
  • The year follows the proleptic Gregorian calendar
  • Python integer arithmetic is sufficient, so overflow handling is not required

Function Signature

def reverse_and_check_year(number, year):
Interviewer

Your question is Reverse Integer Digits and Leap Year. 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.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.