Can Some one help me to Solve this problem?

Date Time

Problem Description

Arun and his sister Usha are challenging each other with some mathematical puzzles. Usha, the cleverer one, has come up with the idea of givingArun 12 distinct digits from 0 to 9, and have him form the largest date time in 2018 with them. Arun is a little nervous, and asks you to help him with a computer program.

Usha will give Arun 12 distinct digits. He needs to create a date time combination in the year 2018: the date in the MM/DD form (all four digits must be present), and the time in the format HH:MM (all four digits must be present). The date may be from 01/01 to 12/31 and the time may be from 00:00 to 23:59 (in the 24 hour format). The digits provided may be used only once in the answer that Arun gives.

If more than one date time combination may be formed, Arun needs to give the latest valid date time possible in the year 2018.

Its a greedy and brute force problem.
Logic: First frame the month, then for each valid month frame date, then for each valid date, frame the hour and for each valid hour frame the minute. Make use of a single array to keep track of the frequency of the digits used. When we use a digit, subtract the frequency and when found invalid add the frequency back to be used later.
Python Soln : DateTime
Java soln : DateTime

Thank you sayan_000

Please connect me in the Hangouts!


haha :rofl::rofl::rofl:

Sorry my bad

it should be: Connect me in Hangouts!!

You sure it’s better? :sweat_smile: