1245. Longest Common Subsequence of Three Strings

HardDynamic ProgrammingString DPLCS

Given three strings a, b, and c, return the length of the longest subsequence common to all three. The input is JSON {a, b, c}.

Input: JSON {a, b, c}.

Output: Integer — the length of the longest common subsequence of all three.

Examples

Example 1
Input: {"a":"geeks","b":"geeksfor","c":"geeksforgeeks"}
Output: 5
Explanation: 'geeks' is common to all three.
Example 2
Input: {"a":"abcd1e2","b":"bc12ea","c":"bd1ea"}
Output: 3
Explanation: 'b1e' is common.
Example 3
Input: {"a":"","b":"a","c":"b"}
Output: 0
Explanation: One string is empty.

Constraints

Asked by

AmazonGoogleMicrosoftMetaAdobe
Solve this problem in the editor →