Suppose an array is given, all elements occur N times, but only one occur K time.
Examples:
N=3, K=1, A = [1,1,1,2,2,3,3,3,4,4,2,4,5]
N=2, K=1, A = [1,1,2,2,3,3,4]
I've just viewed the two threads below:
Number which occurs only once in the array; Using XOR operation, it seems easy to solve this problem when k is odd and n is even.
Given an array that contains all elements thrice except one. Find the element which occurs once. it's harder to find an O(N) of time complexity and O(1) of space complexity algorithm to solve this one.
Can any buddies to give some thoughts on this? Whether is it solvable or not?