Skip to content
CampusEduX

Longest Common Subsequence

Mediumjavapythonccppjavascript

Given two strings, find the length of their longest subsequence that appears in both strings in the same relative order (characters need not be contiguous).

Input Format

The first line contains string A. The second line contains string B. Both consist of lowercase English letters with no spaces.

Output Format

Print the length of the longest common subsequence.

Related Problems

  • House Robber
    Medium · java, python, c, cpp, javascript
    Solve Problem
  • 0/1 Knapsack
    Medium · java, python, c, cpp, javascript
    Solve Problem
  • Longest Increasing Subsequence
    Medium · java, python, c, cpp, javascript
    Solve Problem

Input (stdin)

Output

Run your code to see output here...