Company: Cognizant Technical

Difficulty: easy

Problem Statement

Parity-Locked Interactions A data analytics firm logs its user interactions as an integer array a of size n . Position 0 is the first interaction, position 1 the second, and so on. A data scientist wants to know which interaction values are parity-locked . A value is parity-locked when both of the following hold: it occurs more than once in the array, and every position at which it occurs has the same parity - either all of those positions are even-indexed, or all of them are odd-indexed. Count how many distinct values are parity-locked. Function Description Complete the function countSameParityRepeats with the following parameters: int n : the number of user interactions int a[n] : the interaction values ### Returns int : the number of distinct values that occur more than once and whose occurrences all sit at positions of the same parity Constraints 1 <= n <= 15000 1 <= a[i] <= 10^9 Input Format The first line contains a single integer n , the number of user interactions.

More Cognizant Technical OA questionsInterview experiences