Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. public class optional {
  2. public static String solution(String S) {
  3. int hour = Integer.parseInt(S.substring(0, 2));
  4. int min = Integer.parseInt(S.substring(3, 5));
  5. while (true) {
  6. if (++min == 60) {
  7. min = 0;
  8. ++hour;
  9. hour %= 24;
  10. }
  11. String printOut = String.format("%02d:%02d", hour, min);
  12. Boolean bool = true;
  13. for (int i = 0; i < printOut.length(); ++i)
  14. if (S.indexOf(printOut.charAt(i)) < 0) {
  15. bool = false;
  16. break;
  17. }
  18. if (bool) return printOut;
  19. }
  20. }
  21.  
  22.  
  23. public static void main(String[] args) {
  24. System.out.println(solution("11:01"));
  25.  
  26.  
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement