Compare Calendar Dates
Updated
Problem statement
Given two valid Gregorian calendar dates firstDate and secondDate in dd/mm/yyyy format, return the later date in the same format.
If the dates are equal, return firstDate.
Function
laterDate(firstDate: String, secondDate: String) → StringExamples
Example 1
firstDate = "15/04/2026"secondDate = "20/03/2027"return = "20/03/2027"The year 2027 is later than 2026.
Example 2
firstDate = "29/02/2024"secondDate = "01/03/2024"return = "01/03/2024"March 1 follows February 29 in the leap year 2024.
Example 3
firstDate = "07/09/2030"secondDate = "07/09/2030"return = "07/09/2030"The dates are equal, so the function returns firstDate.
Constraints
- Each input contains exactly
10characters indd/mm/yyyyformat. - Both inputs are valid Gregorian dates with years from
1900through9999. - Day and month values are zero-padded to two digits, and the year is zero-padded to four digits.
More Wells Fargo interview questions
- Count Server ReplacementsOA · PHONE SCREEN · Seen Feb 2026
- Minimum Remaining LengthOA · PHONE SCREEN · Seen Feb 2026
- Count Array Element FrequenciesPHONE SCREEN · Seen May 2025
- Single-Nested Valid Bracket SubstringsPHONE SCREEN · Seen Sep 2020
- Server Upgrade PlanningOA · Seen Nov 2026
- Student and Course EnrollmentOA · Seen Nov 2026
- Bond Interest Summary Above 3%OA · Seen Oct 2026
- Count Phrases Formed by Anagram ReplacementOA · Seen Oct 2026
- Event Statistics AggregatorOA · Seen Sep 2026
- Ordered Deployment Configuration ValidatorOA · Seen Sep 2026
Similar questions at other companies
- Restricted Decimal Number ValidatorLinkedIn · PHONE SCREENLinkedIn interview questions
- Validate Timestamped Message RecordsStripe · PHONE SCREENStripe interview questions
- Extensible Grep Line FilterBloomberg LP · PHONE SCREENBloomberg LP interview questions
- Format CSV Rows as an ASCII TableAmazon · PHONE SCREEN
- CSV Row SerializerMercor · PHONE SCREENMercor interview questions
- Host Log ParserVerkada · PHONE SCREENVerkada interview questions
- Length-Prefixed String CodecSnowflake · PHONE SCREENSnowflake interview questions
- Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
- Machine Message RouterOpenAI · PHONE SCREENOpenAI interview questions
- Parse and Query Server LogsKikoff · PHONE SCREENKikoff interview questions