less than 1 minute read

Given lowercase alphabet strings a, b, and c, return the length of their longest common subsequence.

Constraints

  • 0 ≤ n ≤ 100 where n is the length of a
  • 0 ≤ m ≤ 100 where m is the length of b
  • 0 ≤ k ≤ 100 where k is the length of c

https://binarysearch.com/problems/Longest-Common-Subsequence-of-Three-Strings

Examples

Example 1

Input

  • a = epidemiologist
  • b = refrigeration
  • c = supercalifragilisticexpialodocious

Output

  • answer = 5

Explanation

The longest common subsequence is “eieio”.

Solution

Leave a comment