Back to problems Sign in to unlock
Codeforces
Easy
Arrays
Sorting
IQ test
Find the position of the number whose parity differs from the rest.
Acceptance 0%
Problem Statement
Problem
You are given an array of integers. All numbers are of the same parity except one: either exactly one number is even while all others are odd, or exactly one number is odd while all others are even.
Your task is to determine the 1-based index of that different number.
Input Format
- The first line contains an integer — the number of elements.
- The second line contains integers.
Output Format
- Print one integer: the 1-based position of the element whose parity is different from the others.
Constraints
- Exactly one element has a different parity than all others.
- The answer is guaranteed to exist.
Hints
- Check the parity of the first three elements to identify the majority parity.
- Then scan once to find the outlier.
Input Format
- Integer
- Array of integers
Output Format
- A single integer: the 1-based index of the outlier
Constraints
- Exactly one element has different parity than the rest
- The answer is guaranteed to exist
Examples
Sample cases returned by the problem API.
Example 1
Input
5 2 4 7 8 10
Output
3
Explanation
All numbers are even except 7, which is at position 3.
Example 2
Input
3 9 2 1
Output
2
Explanation
Only 2 is even; the others are odd.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.
Guided hints
Editorial and discussion links
Concept map and variants
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.