Dynamic Programming pattern
Longest Common Subsequence
Given two strings text1 and text2, return the length of their longest common subsequence. A subsequence keeps relative order but need not be contiguous. If there is no common subsequence, return 0. Watch it run step by step, then write your own pseudocode and get it checked by AI.
- LeetCode 1143
- Medium
- 1 approach
Sign in with Google or GitHub and you land straight on this page. DSA comes with the all labs plan and every ChaiCode batch.
Dynamic ProgrammingLeetCode 1143
Medium
The approach
- 01 2-D tabulation O(m·n)O(m·n) space
What you will learn
- How to read Longest Common Subsequence and spot the dynamic programming pattern in it
- 2-D tabulation: O(m·n) time, O(m·n) space
- The pseudocode for each approach, its line lit as the animation runs
- Practice: write your own pseudocode and get it checked
More Dynamic Programming
See Longest Common Subsequence run, step by step
Sign in and this page opens on the animation, with all 18 Dynamic Programming problems beside it.
DSA comes with the all labs plan and every ChaiCode batch.