Leetcode Problem 1507. Reformat Date

1507. Reformat Date

Leetcode Solutions

String Manipulation and Mapping

  1. Create a dictionary to map month abbreviations to their numerical string representation.
  2. Split the input date string into day, month, and year.
  3. Remove the ordinal suffix from the day part and pad with zero if it's a single digit.
  4. Use the dictionary to convert the month abbreviation to a numerical string.
  5. Concatenate the year, numerical month, and day strings with '-' separators to form the final date string in 'YYYY-MM-DD' format.
UML Thumbnail

Regex and Array Indexing

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...