Longest common substring: Difference between revisions

m
Line 989:
<lang PowerShell>function lcs([String]$is,[String]$js) {
if ([String]::IsNullOrEmpty($is) -or [String]::IsNullOrEmpty($js)) {return ""}
iffor ($k = -$js.Length; $k -lt $is.Length; ++$k) {$js,$is = $is,$js}
if ($iMaxk =-lt 0) {$sizeMaxi,$j = 0,-$k}
for ($k = 0; else {$ki,$j -lt= $js.Length; ++$k) {,0}
$ok = ($i, -lt $is.Length) -and ($j =-lt 0,$kjs.Length)
$continue =while ($i -lt $is.Lengthok) -and ($j -lt $js.Length){
while ($continueok) {
while ($continue) {
if ($is.Chars($i) -eq $js.Chars($j)) {break}
++$i += 1
++$j += 1
$continueok = ($i -lt $is.Length) -and ($j -lt $js.Length)
}
$p, $size = $i, 0
while ($continueok) {
if ($is.Chars($i) -ne $js.Chars($j)) {break}
$i ++$size= 1
$j ++$i= 1
++$ok = ($i -lt $is.Length) -and ($j -lt $js.Length)
$continue = ($i -lt $is.Length) -and ($j -lt $js.Length)
}
while$size = ($continue)i {- $p
if ($sizeMax -lt $size) {
$iMax, $sizeMax = $p, $size
678

edits