题目描述
Given an array of size n which contains all elements occurring in multiples of K, except one element which doesn't occur in multiple of K. Find that unique element.
Example 1:
Input :
n = 7, k = 3
arr[] = {6, 2, 5, 2, 2, 6, 6}
Output :
5
Explanation:
Every element appears 3 times except 5.
Example 2:
Input :
n = 5, k = 4
arr[] = {2, 2, 2, 10, 2}
Output :
10
Explanation:
Every element appears 4 times except 10.
Your Task:
You don't need to read input or print anything. Your task is to complete the function findUnique() which takes the array A[], its size N and an integer K as inputs and returns the element with single occurence.
Expected Time Complexity: O(N. Log(A[i]) )
Expected Auxiliary Space: O( Log(A[i]) )
Constraints:
3<= N<=210^{5}
2<= K<=210^{5}
1<= A[i]<=10^{9}
输入格式
见题面
输出格式
见题面