AURIGO Coding Question β Solved
Ticket Distribution
Consider that John has N friends and there are M different types of tickets available for an event. Each friend i, including John (i.e., N + 1 people), possesses some ticket which is represented by a non-negative integer ticket[i]. The value at the last index of the array ticket[] denotes the ticket John has. Out of the N friends that John has, count the number of friends whose binary representation of tickets differs from the binary representation of the ticket John has by at most K integers.
Input Specification:
input1: An integer N denoting the number of John's friends
input2: An integer M denoting the number of types of tickets available
input3: An integer K
input4: An integer array ticket[] of size N+1
Output Specification:
Return an integer value representing the number of John's friends whose tickets differ in at most K bits from the ticket John has.
Example 1:
input1: 2
input2: 3
input3: 2
input4: [5,6,7]
Output: 2
Explanation: The 1st friend's ticket 5 is (0101)β, 2nd friend's ticket 6 is (0110)β, and John's ticket 7 is (0111)β. The bit difference between 5 and 7 is 1, and between 6 and 7 is 1. Both are less than or equal