-
Notifications
You must be signed in to change notification settings - Fork 115
/
1507-ReformatDate.cs
36 lines (33 loc) · 1.07 KB
/
1507-ReformatDate.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//-----------------------------------------------------------------------------
// Runtime: 88ms
// Memory Usage: 23.4 MB
// Link: https://leetcode.com/submissions/detail/368551226/
//-----------------------------------------------------------------------------
using System.Collections.Generic;
namespace LeetCode
{
public class _1507_ReformatDate
{
public string ReformatDate(string date)
{
var months = new Dictionary<string, string>()
{
{ "Jan", "01" },
{ "Feb", "02" },
{ "Mar", "03" },
{ "Apr", "04" },
{ "May", "05" },
{ "Jun", "06" },
{ "Jul", "07" },
{ "Aug", "08" },
{ "Sep", "09" },
{ "Oct", "10" },
{ "Nov", "11" },
{ "Dec", "12" }
};
var split = date.Split(' ');
var day = int.Parse(split[0].Substring(0, split[0].Length - 2));
return $"{split[2]}-{months[split[1]]}-{day:00}";
}
}
}