FastPrepFind the Earliest Formatted Date
Problems/Find the Earliest Formatted Date

Find the Earliest Formatted Date

Morgan Stanley logoMorgan Stanley● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Morgan Stanley online assessment for a full-time role. The report asks for the earliest date. The author gives strings of day, a three-letter English month, and year, with an example that returns 24 Dec 1994. Here we chose valid Gregorian dates, exact zero-padded output, years 1600..9999, the limits, ties going to the first occurrence, and what happens for empty input.

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

Given an array of formatted calendar dates, return the earliest date as its original string. Compare actual calendar chronology, not alphabetical string order.

For this exercise, every input is a valid Gregorian date in exact DD Mon YYYY format: a two-digit day, one space, a case-sensitive English month abbreviation, one space and a four-digit year. Month abbreviations are Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec. Gregorian leap-year rules apply. Dates have no time or time zone.

Return an empty string when the input array is empty. For equal earliest dates, choose the first original occurrence; preserve its exact formatting. Leave the input array unchanged.

Function

earliestDate(dates: String[]) → String

Examples

Example 1

dates = ["13 Jan 2014","24 Dec 1994","08 Feb 2000"]return = "24 Dec 1994"

The years are 2014,1994,2000. The 1994 date is earliest, so return the exact original string 24 Dec 1994.

Example 2

dates = ["31 Jan 2024","01 Feb 2024","02 Jan 2024"]return = "02 Jan 2024"

All years are 2024. January precedes February, and within January, day 2 precedes day 31. Return 02 Jan 2024, preserving the original zero-padded input string.

Constraints

  • For this exercise, assume 0 <= dates.length <= 500.
  • Every date string has exactly 11 characters.
  • Every string is a valid Gregorian date in exact DD Mon YYYY format, with case-sensitive English month abbreviations Jan through Dec and a year between 1600 and 9999, inclusive.

More Morgan Stanley Online Assessment questions

  • Three-Resource 0/1 KnapsackOA · Seen Sep 2026
  • Maximum Concurrent ProcessesOA · ONSITE INTERVIEW · Seen Sep 2026
  • Maximum Total of Nonadjacent RatingsOA · Seen Jul 2026
  • Count Shipment SchedulesOA · Seen Apr 2026
  • Delete and EarnOA · Seen Apr 2026
  • Interleave Array HalvesOA · Seen Apr 2026
  • Get Patch SequenceOA · Seen Feb 2025
  • String Subsequences 🐳OA · Seen Mar 2024
  • Binary Tree Level OrderOA · Seen Feb 2024
  • Merge IntervalsOA · Seen Feb 2024

Similar questions at other companies

  • Count User Mentions in Chat MessagesRamp · OARamp interview questions
  • Blood Type Inheritance: Possible Parent GenotypesAbridge · OAAbridge interview questions
  • Count Repeated Request IDs (Data Science OA)McKinsey & Company · OAMcKinsey & Company interview questions
  • Find a File in a Directory SnapshotCresta · OACresta interview questions
  • Flat JSON Value DifferencesChubb · OAChubb interview questions
  • Road Trip (Analyst Program :PBlackRock · OABlackRock interview questions
  • Get Search ResultsJP Morgan Chase · OAJP Morgan Chase interview questions
  • Lexicographic Word FrequenciesUpstart · OAUpstart interview questions
  • Email Log Processing, Grouping, and SortingStripe · OAStripe interview questions
  • Most Frequent CharacterMicrosoft · OAMicrosoft interview questions

Interview reports that mention this question

  • Morgan Stanley Apprenticeship and Tech Interviews: 6 Experiences

Morgan Stanley interview experiences

  • Morgan Stanley New Grad Technology Analyst: 2 Experiences
  • Morgan Stanley Intern Oldest Loops: 5 Experiences (Part 5 of 5)
  • Morgan Stanley Intern OOP Loops: 5 Experiences (Part 4 of 5)
  • Morgan Stanley Intern Earlier Loops: 5 Experiences (Part 3 of 5)
  • Morgan Stanley Intern Tech Rounds: 5 Experiences (Part 2 of 5)
All Morgan Stanley interview questionsSee Morgan Stanley hiring insights
Saved
class Solution {
    public String earliestDate(String[] dates) {
        // Write your code here.
    }

}
Checking account…