Compare Calendar Dates
Reported by candidates from Wells Fargo's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Wells Fargo reported this one in May 2025, and the input size is the joke: two strings, ten characters each. Nothing to brute force, nothing to optimize. The OA is testing whether you notice that dd/mm/yyyy sorts wrong as plain text and whether you panic over leap years that don't matter. If you've got an invite and 48 hours, this is a five-minute problem you can't afford to overthink. StealthCoder sits in the background as a safety net if you blank on the parsing on the day, but you probably won't need it.
The problem
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) → String Examples 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 10 characters in dd/mm/yyyy format. Both inputs are valid Gregorian dates with years from 1900 through 9999. Day and month values are zero-padded to two digits, and the year is zero-padded to four digits.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is that the format is the wrong order for comparison. Comparing the raw strings gives you day first, which is wrong. Slice the year (index 6 to 10), month (3 to 5), and day (0 to 2), convert each to an integer, and compare as the tuple (year, month, day). Return secondDate only if its tuple is strictly greater, otherwise return firstDate. That strict check covers the equal-dates rule for free. The common pitfall is writing leap-year logic or converting to day counts. You don't need any of it, because both dates are guaranteed valid, so February 29 and March 1 compare correctly by month alone. Another trap is returning a reformatted string and losing the zero padding. Just return the original input string untouched. Time and space are both constant. If you freeze on index slicing mid-assessment, StealthCoder is the hedge that hands you the comparison order instantly.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
You can drill Compare Calendar Dates cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. If you're reading this with an OA window open, you're who this was built for.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Wells Fargo's OA.
Wells Fargo reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Compare Calendar Dates FAQ
How hard is Compare Calendar Dates really?+
It's easy. Two fixed-length strings, no loops, no data structures. The only real work is parsing and comparing in the right order. If you've written any string slicing in your language, you can finish it in a few minutes.
What's the trick to this Wells Fargo OA question?+
Compare year first, then month, then day. The input is dd/mm/yyyy, so a plain string comparison fails. Build a tuple or a single key like year*10000 + month*100 + day, and compare those numbers.
Do I need to handle leap years?+
No. Both inputs are guaranteed valid Gregorian dates, so 29/02/2024 is already legal. You never validate or add days, you only compare. Leap-year code is wasted effort and a chance to introduce bugs.
What happens when the dates are equal?+
Return firstDate. If you only switch to secondDate when its key is strictly greater, equal dates fall through to firstDate automatically. Don't use a greater-or-equal check, that flips the answer on ties.
How do I prepare for this in 48 hours?+
Practice parsing fixed-format strings and comparing multi-field keys in your chosen language. Write this function once from memory, test the three examples, and move on. Spend the rest of your time on harder array and hash map problems.