1507. Reformat Date
Easy
Given a date
string in the form Day Month Year
, where:
Day
is in the set{"1st", "2nd", "3rd", "4th", ..., "30th", "31st"}
.Month
is in the set{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}
.Year
is in the range[1900, 2100]
.
Convert the date string to the format YYYY-MM-DD
, where:
YYYY
denotes the 4 digit year.MM
denotes the 2 digit month.DD
denotes the 2 digit day.
Example 1:
Example 2:
Example 3:
Constraints:
The given dates are guaranteed to be valid, so no error handling is necessary.
解題
醜陋但是跑得快的解法:
Runtime: 0 ms, faster than 100.00%
Memory Usage: 2.1 MB, less than 38.71%
討論區看到的漂亮解法:
Previous1502. Can Make Arithmetic Progression From SequenceNext1509. Minimum Difference Between Largest and Smallest Value in Three Moves
Last updated