-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBigNum.java
More file actions
30 lines (28 loc) · 828 Bytes
/
BigNum.java
File metadata and controls
30 lines (28 loc) · 828 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
30
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
public class BigNum {
public List<Integer> solution(int n, int[] arr){
List<Integer> answer = new ArrayList<>();
answer.add(arr[0]);
for (int i = 1 ; i < n; i++){
if(arr[i] > arr[i-1])
answer.add(arr[i]);
}
return answer;
}
public static void main(String[] args) {
BigNum t = new BigNum();
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[] arr = new int[n];
for (int i=0; i < n; i++){
arr[i] = scanner.nextInt();
}
List<Integer> solution = t.solution(n, arr);
for (Integer i : solution) {
System.out.print(i + " ");
}
}
}