07 - Longest Common Subsequence - Dynamic Programming approach

@Rishi Srivastava Using the same recursive algorithm - transform the algorithm using Dynamic Programming Bottom Up approach Pseudo code: int[][] dp = new int[row 1][col 1]; for (int i = row - 1; i greater than or equal to 0; i--) { for (int j = col - 1; j greater than or equal to 0; j--) { if ((i) == (j)) { dp[i][j] = 1 dp[i 1][j 1]; } else { dp[i][j] = MAX(dp[i][j 1], dp[i 1][j]); } } } return dp[0][0]; Time complexity: O( * ) Space complexity: O( * ) Github: Leetcode:
Back to Top