Posted: Sat Feb 23, 2008 4:29 pm Post subject: Critique my solution please.
Hey guys. In my quest to learn dynamic programming techniques, I've solved the S4 problem from the 2007 CCC. To my great pleasure, my solution seems to work and is fast. I'm happy with it, but I'm wondering if I'm doing something wrong. I'd appreciate if someone could look over my C++ solution and tell me if I'm doing something wrong or not doing something right.
int calculateNWays(int nodeNum)
{
if (nodeNum == 1){
return nWays[1]; //One way to get to the first node.
}
else if (nWays[nodeNum] != 0)
{
return nWays[nodeNum];
}
else
{
int ways(0);