-
Notifications
You must be signed in to change notification settings - Fork 0
/
D.java
47 lines (35 loc) · 863 Bytes
/
D.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
/*
// problem: https://open.kattis.com/contests/naq19open/problems/missingnumbers
import java.util.*;
class Main {
public static Queue<Integer> missingNumbers(int[] nums){
Queue<Integer> q = new LinkedList<>();
// grab the final number
int prev = 1;
int curr = 0;
for (int i = 0; i < nums.length; i++)
{
curr = nums[i];
while (prev < curr)
{
q.add(prev);
prev++;
}
prev = curr + 1;
}
return q;
}
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] arr = new int[n];
for(int i = 0; i < n; i++)
arr[i] = in.nextInt();
Queue<Integer> q = missingNumbers(arr);
if (q.isEmpty())
System.out.println("good job");
while(!q.isEmpty())
System.out.println(q.remove());
}
}