-
Notifications
You must be signed in to change notification settings - Fork 5
/
Time Conversion (HackerRank)
63 lines (46 loc) · 1.25 KB
/
Time Conversion (HackerRank)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;
public class Solution {
/*
* Complete the timeConversion function below.
*/
static String timeConversion(String s) {
/*
* Write your code here.
*/
char[] array = s.toCharArray();
if(array[8] == 'P')
{
if(array[0] == '1' && array[1] == '2')
{
}
else {
int a = (int) array[0];
int b = (int) array[1];
int suma = a+1;
int sumb = b+2;
array[0] = (char) suma;
array[1] = (char) sumb;
}
}
else if(array[0] == '1' && array[1] == '2')
{
array[0] = '0';
array[1] = '0';
}
String final1 = "";
for(int i=0;i<array.length-2;i++)
{
final1 += ""+array[i];
}
return final1;
}
private static final Scanner scan = new Scanner(System.in);
public static void main(String[] args) throws IOException {
String s = scan.nextLine();
System.out.println(timeConversion(s));
}
}