Back to General discussions forum
Shouldn't the sweet count for the first case of the example input data be 47 instead of 48?
Thanks.
This modifies my approach to the problem, as I initially thought of it as just evaluation the next two possible outcomes. Any reading to give me a hint on the reasoning for this?
must he start at the first isle or can he begins at the second??
for this example :
3 12 7 13 12 4 5 13 11 17 16 6 13 5 19 15 7 7 7 6 8 here are the steps [3, 12, 10, 16, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 54, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 54, 56, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 54, 56, 60, 69, 0, 0, 0, 0, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 54, 56, 60, 69, 65, 0, 0, 0, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 54, 56, 60, 69, 65, 88, 0, 0, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 54, 56, 60, 69, 65, 88, 84, 0, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 54, 56, 60, 69, 65, 88, 84, 95, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 54, 56, 60, 69, 65, 88, 84, 95, 95, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 54, 56, 60, 69, 65, 88, 84, 95, 95, 102, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 54, 56, 60, 69, 65, 88, 84, 95, 95, 102, 101, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 54, 56, 60, 69, 65, 88, 84, 95, 95, 102, 101, 110] i found 110 but the annwser must be 108 !!
Hi mooninvader, the rabbit starts from the first isle (Marked X). Let's take the first four numbers from your example. Rabbit can jump from first isle to either a or b:
3 12 7 13 ... 8
X a b
Since this is a dynamic programming problem, it might help to instead visualize it as:
0 0 3 12 7 13 ... 8
a b X
-------->
0 0 3 12 7 13 ... 8
a b X
--------->
EDIT: Oops, Graeme answered before me! It is indeed 3+7+12+5+11+16+13+19+7+7+8
thanks a lot so the value of the second isle is never used.. i replaced it with the value of the first added two zeros at the begenning of the array and it works fine now.
thank you WakeMeAtThree and Quandray