Answers for "java LCS"

1

LCM with java

/*
Easiest but slowest method
*/
class LCM 

{ 

    static void find_LCM(int num1, int num2) 

    { 

        System.out.println("Number 1: " + num1); 

        System.out.println("Number 2: " + num2); 

        long check_num = 1; 

        while (true) 

        { 

            if ((check_num%num1) == 0 && (check_num%num2) == 0) 

            { 

                 long LCM = check_num; 

                 System.out.println("The LCM is: " + LCM); 

                 break; 

            } 

            else  

                ++check_num; 

        }  

    } 

}
Posted by: Guest on July-12-2021
0

python lcs length

def lcs(X, Y):
  
    n = len(Y)
    m = len(X)
    
    L = [[None]*(n + 1) for i in range(m + 1)]
    for i in range(m + 1): 
        for j in range(n + 1): 
            if i == 0 or j == 0 : 
                L[i][j] = 0
            elif X[i-1] == Y[j-1]: 
                L[i][j] = L[i-1][j-1]+1
            else: 
                L[i][j] = max(L[i-1][j], L[i][j-1])
                
    return L[m][n]
Posted by: Guest on October-15-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language