Myvideo

Guest

Login

07 - Longest Common Subsequence - Dynamic Programming approach

Uploaded By: Myvideo
1 view
0
0 votes
0

@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:

Share with your friends

Link:

Embed:

Video Size:

Custom size:

x

Add to Playlist:

Favorites
My Playlist
Watch Later