Oops, missed the undef.
But note that starting at one has nothing to do with the dynamic programming technique. If you wanted to start at zero (say if @S and @T are inputs to the function), then just replace
with$L[$i-1][$j-1] ||= 0; $L[$i][$j] = $L[$i-1][$j-1] + 1;
if ($i && $j) { $L[$i-1][$j-1] ||= 0; $L[$i][$j] = $L[$i-1][$j-1] + 1; } else { $L[$i][$j] = 1; }
In reply to Re^3: LCS efficiency problem
by ikegami
in thread LCS efficiency problem
by zhe
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |