FastPrepNext Date With All Different Digits
Problems/Next Date With All Different Digits

Next Date With All Different Digits

Jane Street logoJane Street● EasyNEW GRADFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in four Jane Street trading desk operations interview reports posted from 2020 to 2022, all in the phone round. Two graduate candidates were asked for the next date, written as day, month and year digits, on which all of the digits are different; one used a 2020 date only to show the digit format. The other two reports only mention a date-format puzzle.

In the interview it was a mental puzzle about one starting date. We turned it into a function that takes any starting date and returns the answer. Starting example 1 from that 2020 date is our choice, and so are the 1900 to 9000 year range and the 1965 and 1956 examples.

Our version is about 90% the same as the reported question.

Write a date as eight digits: the day with two digits, the month with two digits and the year with four digits. For example, 10 May 2020 is written 10052020, and 3 January 1999 is written 03011999.

You are given a date as day, month and year in the Gregorian calendar. Find the first date strictly after it whose eight digits are all different.

Return that date as [day, month, year].

Leap years follow the usual rule: a year is a leap year if it is divisible by 4, except years divisible by 100 that are not divisible by 400.

Function

nextDistinctDigitDate(day: int, month: int, year: int) → int[]

Examples

Example 1

day = 10month = 5year = 2020return = [17,6,2345]

Every month from 01 to 12 uses a 0 or a 1, and every day starts with 0, 1, 2 or 3. Checking the cases, a day and a month together always use at least two digits from 0, 1, 2, 3, and a year in the 2000s already uses the 2. That rules out every year that starts with 20, 21 or 22. The first year from 2300 on with four different digits that leaves both 0 and 1 free is 2345. The day and month must then take 0, 1 and two of 6, 7, 8, 9. The earliest such date is day 17 of month 06, written 17062345.

Example 2

day = 23month = 4year = 1965return = [27,4,1965]

The next days are 24041965, 25041965 and 26041965, which repeat 4, 5 and 6. The day after that is 27041965, and its eight digits are all different.

Example 3

day = 31month = 12year = 1956return = [24,3,1957]

The year 1957 uses 1, 9, 5 and 7. January (01) repeats the 1. In February (02) the month uses 0 and 2, so the day would have to start with 3, and February has no day 30 or 31. In March (03) the day must start with 2, and the smallest free second digit is 4. So the answer is 24031957.

Constraints

  • 1900 <= year <= 9000
  • 1 <= month <= 12
  • 1 <= day <= 31
  • day, month and year form a real date.

More Jane Street Phone Screen questions

  • Maximum-Scoring Consecutive Tree LevelsPHONE SCREEN · Seen Nov 2026
  • Tree Selection and VisibilityPHONE SCREEN · Seen Nov 2026
  • Load/Store Arithmetic InterpreterPHONE SCREEN · Seen Oct 2026
  • Instrument Stack Language JumpsPHONE SCREEN · Seen Oct 2026
  • Run a Stack Language InterpreterPHONE SCREEN · Seen Oct 2026
  • Positive-Integer Expression EvaluationPHONE SCREEN · Seen Oct 2026
  • Add Two Integers Given as StringsPHONE SCREEN · Seen Sep 2026
  • Angle Between Clock HandsPHONE SCREEN · Seen Jul 2026
  • Route Length From Two CyclistsPHONE SCREEN · Seen Jul 2026
  • Sort TradesPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026

Similar questions at other companies

  • Automation Pipeline, Part 1: Single WorkerPlaid · PHONE SCREENPlaid interview questions
  • Subtract Two Large Number StringsStackAdapt · PHONE SCREENStackAdapt interview questions
  • Fair Coin from a Biased CoinAnthropic · PHONE SCREENAnthropic interview questions
  • Three Points in a Semicircle: Monte Carlo EstimateSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
  • Apply Affine Array TransformationsByteDance · PHONE SCREENByteDance interview questions
  • Exponential Backoff DelaysWonderful · PHONE SCREEN
  • Fizz and Buzz Words From 1 to nDocuSign · PHONE SCREENDocuSign interview questions
  • Recover Document Hierarchy from IndentationReducto · PHONE SCREEN
  • Smaller Clock Hand AngleAmazon · PHONE SCREEN
  • Count Months Starting on SundayWalmart · PHONE SCREENWalmart interview questions

Interview reports that mention this question

  • Jane Street TDO UK and Hong Kong: 22 Experiences (Part 10 of 10)
  • Jane Street TDO Earlier US Finals: 19 Experiences (Part 7 of 10)
  • Jane Street TDOE New Grad Interview Questions: 11 Experiences

Jane Street interview experiences

  • Jane Street TDOE US Final Round: 11 Experiences (Part 5 of 10)
  • Jane Street TDO Phone Math Round: 26 Experiences (Part 9 of 10)
  • Jane Street TDOE UK Phone Screen: 15 Experiences (Part 4 of 10)
All Jane Street interview questionsSee Jane Street hiring insights
Saved
class Solution {
    public int[] nextDistinctDigitDate(int day, int month, int year) {
      // Write your code here.
    }
}
Checking account…