-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMumbleRap.java
More file actions
39 lines (36 loc) · 1.06 KB
/
Copy pathMumbleRap.java
File metadata and controls
39 lines (36 loc) · 1.06 KB
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
import java.util.ArrayList;
import java.util.Scanner;
public class MumbleRap {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
sc.nextLine();
System.out.println(mumbleRap(sc.nextLine()));
sc.close();
}
public static int mumbleRap(String word) {
int max = 0, start, end;
ArrayList<Integer> list = new ArrayList<>();
for (int i = 0; i < word.length(); i++) {
if(!Character.isDigit(word.charAt(i))){
continue;
}
else{
start = i;
while(i < word.length() && Character.isDigit(word.charAt(i))){
i++;
}
end = i;
}
list.add(Integer.parseInt(word.substring(start, end)));
}
max = findMax(list);
return max;
}
private static int findMax(ArrayList<Integer> list) {
int max = 0;
for (Integer integer : list) {
if(integer > max) max = integer;
}
return max;
}
}