AURIGO Coding Question – Solved

8 Live
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

Asked in: AURIGO

Image of the Question

Question Image Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| Given an n x m grid, where rows are numbered from 7 to n and columns from 1 to … |
| There are 'N' coders standing in a line, where i denotes the ith position of a … |
| A birthday party was attended by N number of kids, and each kid was given a uni… |
| Given a matrix of size m * n, where m denotes the number of rows (starting with… |
| A traveler is traveling from the city of Zeta to Omega. He starts with X amount… |
| As an operations engineer at Amazon, you are responsible for organizing the dis… |