GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Improved visualization for LIS · mohaike/AlgorithmVisualizer@da95a9f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • algorithm/dp/longest_common_subsequence/basic
    • code.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎algorithm/dp/longest_common_subsequence/basic/code.js‎

Copy file name to clipboardExpand all lines: algorithm/dp/longest_common_subsequence/basic/code.js
+22-1Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,25 @@ var i,j;
3333
}
3434
}
3535

36-
logger._print ( 'Longest Common Subsequence is ' + A[m][n] );
36+
var finalString = '';
37+
i=m;
38+
j=n;
39+
while( i>=1 && j>=1 ) {
40+
41+
tracer3._select ( i, j )._wait ();
42+
if( string1[i-1] == string2[j-1] ) {
43+
tracer1._select ( i-1 )._wait ();
44+
tracer2._select ( j-1 )._wait ();
45+
46+
finalString = string1[i-1] + finalString;
47+
i--;
48+
j--;
49+
} else if( A[i-1][j] > A[i][j-1] ) {
50+
i--;
51+
} else {
52+
j--;
53+
}
54+
}
55+
56+
logger._print ( 'Longest Common Subsequence Length is ' + A[m][n] );
57+
logger._print ( 'Longest Common Subsequence is ' + finalString );

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.