in reply to Re^2: LCS efficiency problem
in thread LCS efficiency problem

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

$L[$i-1][$j-1] ||= 0; $L[$i][$j] = $L[$i-1][$j-1] + 1;
with
if ($i && $j) { $L[$i-1][$j-1] ||= 0; $L[$i][$j] = $L[$i-1][$j-1] + 1; } else { $L[$i][$j] = 1; }