1class Solution {2public:3string reformatDate(string date) {4// easiest way to get index with O(1)5unordered_map<string, string> months = {6{"Jan", "01"}, {"Feb", "02"}, {"Mar", "03"}, {"Apr", "04"}, {"May", "05"}, {"Jun", "06"},7{"Jul", "07"}, {"Aug", "08"}, {"Sep", "09"}, {"Oct", "10"}, {"Nov", "11"}, {"Dec", "12"}};8istringstream s(date);9// get day10string day;11s >> day;12day.pop_back();13day.pop_back();14if (day.size() == 1) day = "0" + day;15// get month16string month;17s >> month;18// get year19string year;20s >> year;21return year + "-" + months[month] + "-" + day;22}23};