We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
What does Optimally in the problem description means:
How many continuous subsequences of chocolate piles will Laurel win if both of them play optimally?
For the sequence of 1,1,2 the exmaple said, Laurel will lose but if we play it two different ways, each win in one way: (This assumes 0,0 is a non-decreasing sequence)
Way 1:
Initial-> [1, 1, 2]
[0, 1, 2] --> Laurel Moved
[0, 0, 2] --> Hardy Moved
[0, 0, 0] --> Laurel Moved, so Laurel won
Way 2:
Initial-> [1, 1, 2]
[0, 1, 2] --> Laurel Moved
[0, 1, 1] --> Hardy Moved
[0, 0, 1] --> Laurel Moved
[0, 0, 0] --> Hardy Moved, so Hardy won
I understood from the following comment that 0 is a valid entry of a chocolate pile and derivatively all 0s is the final sequence where the game should stop.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Chocolate Game
You are viewing a single comment's thread. Return to all comments →
What does Optimally in the problem description means:
How many continuous subsequences of chocolate piles will Laurel win if both of them play optimally?
For the sequence of 1,1,2 the exmaple said, Laurel will lose but if we play it two different ways, each win in one way: (This assumes 0,0 is a non-decreasing sequence)
Way 1: Initial-> [1, 1, 2] [0, 1, 2] --> Laurel Moved [0, 0, 2] --> Hardy Moved [0, 0, 0] --> Laurel Moved, so Laurel won
Way 2: Initial-> [1, 1, 2] [0, 1, 2] --> Laurel Moved [0, 1, 1] --> Hardy Moved [0, 0, 1] --> Laurel Moved [0, 0, 0] --> Hardy Moved, so Hardy won
I understood from the following comment that 0 is a valid entry of a chocolate pile and derivatively all 0s is the final sequence where the game should stop.