-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUrlify.java
More file actions
29 lines (26 loc) · 790 Bytes
/
Urlify.java
File metadata and controls
29 lines (26 loc) · 790 Bytes
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
class Solution {
public static void main(String[] args){
char[] input = "Mr John Smith ".toCharArray();
System.out.println(input);
replaceSpaces(input, 13);
System.out.println(input);
System.out.println('b'-'a');
}
public static void replaceSpaces(char[] str, int trueLength){
int index = str.length;
for (int i = trueLength - 1; i > 0; i--){
if (str[i] == ' '){
str[index - 1] = '0';
str[index - 2] = '2';
str[index - 3] = '%';
index = index - 3;
} else {
str[index - 1] = str[i];
index--;
}
}
}
public static Boolean palPerm(String s){
return true;
}
}