1]; for ($i = $jolt_count - 2; $i >= 0; $i--) { $count = 0; for ($j = $i + 1; $j < $jolt_count && $joltages[$j] - $joltages[$i] <= 3; $j++) { $count += $memo[$j]; } $memo[$i] = $count; } return $memo[0]; }