IQ Test Problem
IQ Test Problem — ExecCode Medium DSA Practice
Solve the IQ Test problem on ExecCode. Free online medium DSA practice in Two Pointers. Write and run code in Java, C++, Python — no signup required to run.
Problem description
You are given an array where every value has the same parity except exactly one. Return the 1-based index of the single value whose parity is different from the others. You are given: a — the numbers Return the 1-based index of the different-parity value. Parity means even or odd. The different value may be the only even number or the only odd number.
Examples
Input {'a': [2, 4, 7, 8, 10]}; Output 3. Input {'a': [1, 2, 1, 1]}; Output 2. Input {'a': [3, 5, 7, 8]}; Output 4
Constraints
3 <= a.length <= 100000 Exactly one value has a different parity from the rest 1 <= a[i] <= 1000000000
Practice IQ Test free on ExecCode. Browse DSA problems, topic map, and placement guides.