-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathURIDecoding.java
56 lines (53 loc) · 1.02 KB
/
URIDecoding.java
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
package Algospot.beginner;
import java.util.Scanner;
public class URIDecoding {
public String solution(String str) {
String result = "";
for(int i = 0; i < str.length(); i++){
char target = str.charAt(i);
if(target == '%') {
char k = str.charAt(i+2);
switch(k) {
case '0' :
result += " ";
break;
case '1' :
result += "!";
break;
case '4' :
result += "$";
break;
case '5' :
result += "%";
break;
case '8' :
result += "(";
break;
case '9' :
result += ")";
break;
case 'a' :
result += "*";
break;
default :
break;
}
i += 2;
}
else {
result += target;
}
}
return result;
}
public static void main(String[] args) {
URIDecoding test = new URIDecoding();
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for(int test_case = 1; test_case <= t; test_case++) {
String str = sc.next();
System.out.println(test.solution(str));
}
sc.close();
}
}