Menu

(Solved) : Java Watch Displays Current Time 24 Hour Format Look Digits Used Display Time Wonder Last Q37273870 . . .

JAVA: You have a watch that displays the current time in 24-hourformat. you look at the digits used to display the time and wonder:what was the last time that could be displayed using the samesubset of digits?

Write a function:

             class Solution { public String solution(String S); }

that, given a non-empty string S in “HH : MM” formatrepresenting the current time on your watch, returns the string Tin the same format, specifying the latest time before that can berepresented by a subset of the digits of S (note that not alldigits from S have to be used).

For example, given “11 : 01” your function should return “11 :00”. For “11 : 13” the result should be “11 : 11”. For “22 : 22”the result should be “22 : 22” (the time occurred on the previousday).

Assume that:

             String S is a valid time in “HH : MM” format from “00 : 00” to “23: 59 “.

In your solution, focus on correctness. The performance of yoursolution will not be the focus of the assessment.

Expert Answer


Answer to JAVA: You have a watch that displays the current time in 24-hour format. you look at the digits used to display the time…

OR