Sponsored
Use these hints if you're stuck. Try solving on your own first.
There are limited outcomes given the current sum and the stones remaining.
Can we greedily simulate starting with taking a stone with remainder 1 or 2 divided by 3?
Solve with full IDE support and test cases