Johnny likes to watch the clock. He likes some moments more than others. The time "HH:MM" is good if you can split the four digits into two adjacent groups such that the products of the digits within each group are equal. Each group must contain at least one digit, so there are totally 3 possible ways to do the split: "H" and "H:MM", "HH" and "MM", or "HH:M" and "M". For example, "22:28" is good because you can split it into "22:2" and "8", and 2 * 2 * 2 = 8. "23:32" and "10:00" are also good, while "23:45" and "12:42" are not.
You are given two Strings, beforeTime and afterTime, each formatted as "HH:MM" (quotes for clarity). The two times are less than 24 hours apart. Return the number of good times between beforeTime and afterTime, inclusive.
|