Top Coding Interview Question – Solved

5 Live
Winner Winner Alice and Bob are playing a game to decide who is better. They both play alternatively. Alice starts first. The subjects and the books are read sequentially. The rules of the game are as follows: - Both of them have N subjects. - Let array S denote the number of books in each subject. - Let array P denote the points for completing a book in a particular subject. - All books on one subject have the same points. In one move, a player has to complete the following steps: - They can skip all books of a subject if they want. They can keep skipping books till they want. Skip here means that the books of the subject become unavailable to read for both of them. As a result, the whole subject becomes unavailable. The player has the choice to skip subjects as long as he wants without losing his turn. - They read one book on a subject if it is available. On reading the book, the points of that person increase by P[i] where P[i] is the points for completing the book. So the number of books on that particular subject decreases by one. Note that he can read only one book in this step. The chance immediately goes to the other person just after he reads. If no book is available, the game ends. The other person continues with the remaining subjects and the remaining books. The game goes on alternatively until no book is available to read.

Asked in: No companies listed

Image of the Question

Question Image Question Image

All Testcases Passed βœ”



Passcode Image 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… |