Untitled
unknown
plain_text
2 years ago
751 B
6
Indexable
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int k = scanner.nextInt();
scanner.nextLine(); // Consume newline
String[] sequence = scanner.nextLine().split(" ");
int count = 0;
int result = -1;
for (String num : sequence) {
int n = Integer.parseInt(num);
if (n == -1) break; // Stop when encountering -1
if (n % 2 != 0) {
count++;
if (count == k) {
result = n;
break;
}
}
}
System.out.println(result);
}
}Editor is loading...
Leave a Comment