Top Coding Interview Question – Solved

11 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

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