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.
Ya, there's a theory called- "Impartial Games" which deals with the cases when there are only two player and they either win or lose.
In face the problem is easy and can be coded with DP [O(n) solution], without finding the exact relationship (until the test cases are too large, you dont need the O(1) solution;IN CASE YOU NEED- still you can use the DP sol to get the table, and find the relation without hand coding every case ).
I first suggest you to Understand THIS problem. (as the same theory will be required many times). and then see the Impartial Games, as they can have many Extra Material you don't want.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Game of Stones
You are viewing a single comment's thread. Return to all comments →
Ya, there's a theory called- "Impartial Games" which deals with the cases when there are only two player and they either win or lose.
In face the problem is easy and can be coded with DP [O(n) solution], without finding the exact relationship (until the test cases are too large, you dont need the O(1) solution;IN CASE YOU NEED- still you can use the DP sol to get the table, and find the relation without hand coding every case ).
I first suggest you to Understand THIS problem. (as the same theory will be required many times). and then see the Impartial Games, as they can have many Extra Material you don't want.