Longest Common Subsequence (2 Strings) - Dynamic Programming & Competing Subproblems @BackToBackSWE
Longest Common Subsequence (2 Strings) - Dynamic Programming & Competing Subproblems  @BackToBackSWE
Uploaded February 2019 | Updated November 2026, 3 days ago
Code & Problem Statement @ backtobackswe.com/platform/content/longest-common-subsequence/video?utm_source=youtube&utm_medium=video

Free 5-Day Mini-Course: backtobackswe.com
Try Our Full Platform: backtobackswe.com/pricing
๐Ÿ“น Intuitive Video Explanations
๐Ÿƒ Run Code As You Learn
๐Ÿ’พ Save Progress
โ“New Unseen Questions
๐Ÿ”Ž Get All Solutions


Question: You are given 2 strings. Return the length of the longest subsequence that the 2 strings share.

Complexities

n = s1.length()
m = s2.length()

Time: O( nm )

We can upper bound time by the number of subproblems that we are going to solve.

Space: O( nm )

We upper bound space by the number of subproblems we will story answers to. Whether we do (n + 1)(m + 1) or (n)(m) doesn't matter asymptotically.


++++++++++++++++++++++++++++++++++++++++++++++++++

HackerRank: youtube.com/channel/UCOf7UPMHBjAavgD0Qw5q5ww

Tuschar Roy: youtube.com/user/tusharroy2525

GeeksForGeeks: youtube.com/channel/UC0RhatS1pyxInC00YKjjBqQ

Jarvis Johnson: youtube.com/user/VSympathyV

Success In Tech: youtube.com/channel/UC-vYrOAmtrx9sBzJAf3x_xw
Longest Common Subsequence (2 Strings) - Dynamic Programming & Competing SubproblemsBinary Tree Bootcamp: Full, Complete, & Perfect Trees. Preorder, Inorder, & Postorder Traversal.Knuthโ€“Morrisโ€“Pratt (KMP) Pattern Matching Substring Search -  First Occurrence Of SubstringThe Balanced Parentheses Problem - Classic Stack Problem (Valid Parentheses on Leetcode)3 Test Cases You Should Always Keep in Mind #shorts #datastructuresTotal Unique Ways To Make Change - Dynamic Programming (Coin Change 2 on LeetCode)How I Got An Internship @ TwitterThe Dutch National Flag Problem (The Quicksort Band-Aid)Search A 2D Sorted Matrix - Fundamentals of Search Space ReductionHow To Permute A String - Generate All Permutations Of A StringMerge 2 Sorted Lists - A Fundamental Merge Sort Subroutine (Merge Two Sorted Lists on LeetCode)Count Total Unique Binary Search Trees - The nth Catalan Number (Dynamic Programming)
Back To Back SWE |

Longest Common Subsequence (2 Strings) - Dynamic Programming & Competing Subproblems

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER