Skip to content

Instantly share code, notes, and snippets.

@webmonch
Created October 5, 2014 20:32
Show Gist options
  • Save webmonch/8f37d7d99fb4108b1a4e to your computer and use it in GitHub Desktop.
Save webmonch/8f37d7d99fb4108b1a4e to your computer and use it in GitHub Desktop.
Lost card
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String [] args) throws IOException {
//Scanner sc = new Scanner(new File("data.txt"));
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
while (sc.hasNextInt()) {
int ammount = sc.nextInt();
boolean [] nums = new boolean[ammount];
int index = 0;
for (int i = 0; i < ammount-1; ++i) {
int num = sc.nextInt();
nums[num-1] = true;
}
int res = 0;
for (int i = 0; i < nums.length; ++i) {
int num = i+1;
if (nums[i] == false) {
res = num;
break;
}
}
out.println(res);
out.flush();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment