Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

319
Views
longest common substring Multiple Input in JS
function LCSubStr(X, Y) {

    let m = X.length;
    let n = Y.length;


    let result = 0;


    let end;


    let len = new Array(4);
    for (let i = 0; i < len.length; i++) {
        len[i] = new Array(n);
        for (let j = 0; j < n; j++) {
            len[i][j] = 0;
        }
    }


    let currRow = 0;


    for (let i = 0; i <= m; i++) {
        for (let j = 0; j <= n; j++) {
            if (i == 0 || j == 0) {
                len[currRow][j] = 0;
            }
            else if (X[i - 1] == Y[j - 1]) {
                len[currRow][j] = len[1 - currRow][j - 1] + 1;
                if (len[currRow][j] > result) {
                    result = len[currRow][j];
                    end = i - 1;
                }
            }
            else {
                len[currRow][j] = 0;
            }
        }


        currRow = 1 - currRow;
    }


    if (result == 0) {
        return "-1";
    }

    return X.substr(end - result + 1, result);
}

// Driver Code
let X = "GeeksforGeeks";
let Y = "GeeksQuiz";
// function call
document.write(LCSubStr(X, Y));

How can I convert this code for multiple input?

I checked many lcs code but no one works with

ABCQEFDEFGHIJ BCXEFGYZBCDEWEFGHU > EFGH

This one just works good without any problem. I should convert this one for multiple input in Javascript.

Now we have X,Y but it shoulde be with multiple inputs.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!