Company: Wipro_14march
Difficulty: medium
There is a string representing a date in "MM-DD" format, where MM denotes a month in a two-digit format and DD denotes a day in a two-digit format. Some digits were replaced by "?". Replace all the question marks with digits (0-9) in such a way as to obtain the latest possible date. Assume that the maximum number of days in each month is as follows: | month | number of days +---------------+--------------- 01 | January | 31 02 | February | 28 03 | March | 31 04 | April | 30 05 | May | 31 06 | June | 30 07 | July | 31 08 | August | 31 09 | September | 30 10 | October | 31 11 | November | 30 12 | December | 31 Write a function: class Solution { public String solution(String date); } that, given a string date , returns the latest valid date as a string in the format "MM-DD". If it is not possible to obtain any valid date, return the string "xx-xx". Examples: Assuming date = "?1-31" , the date is clearly from January (01) or November (11). Only January has 31 days, so the function should r