Facebook Pixel

Longest Common Subsequence

Problem Statement

Given two strings, find the length of their longest common subsequence (LCS).

A subsequence is formed by deleting some (or no) characters without changing the order of remaining characters. For example, "ace" is a subsequence of "abcde" (delete b, d), but "aec" is not (wrong order).

word1 = "abcde"
word2 = "ace"

LCS = "ace", length = 3
Invest in Yourself
Your new job is waiting. 83% of people that complete the program get a job offer. Unlock unlimited access to all content and features.
Go Pro