AURIGO Coding Question – Solved

6 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

| You are given a board of size M Γ— N where each cell can be either empty ('O') o… |
| Undirected Coloured Graph Shortest Path You are given an undirected weight… |
| Village Voyage A computer game "Village Voyage" has N villages (labeled 1 to… |
| Academic Decathlon Students are being selected for an academic decathlon tea… |
| Sum of Arrays Given two arrays each of length n, arr1 and arr2, in one opera… |
| Count Swaps During Custom Sorting Analyze the efficiency of the following so… |