Showing:
Handle Score
@Ibrahim Nash 6564
@mb1973 5785
@Quandray 5275
@akhayrutdinov 5111
@saiujwal13083 5074
@kirtidee18 4639
@sanjay05 3762
@mantu_singh 3712
@gfgaccount 3627
@marius_valentin_dragoi 3525
LCS of three strings
Medium Accuracy: 63.53% Submissions: 8017 Points: 4

Given 3 strings A, B and C, the task is to find the longest common sub-sequence in all three given sequences.

Example 1:

Input:
A = "geeks", B = "geeksfor",
C = "geeksforgeeks"
Output: 5
Explanation: "geeks"is the longest common
subsequence with length 5.


â€‹Example 2:

Input:
A = "abcd", B = "efgh", C = "ijkl"
Output: 0
Explanation: There's no common subsequence
in all the strings.


You don't need to read input or print anything. Your task is to complete the function LCSof3() which takes the strings A, B, C and their lengths n1, n2, n3 as input and returns the length of the longest common subsequence in all the 3 strings.

Expected Time Complexity: O(n1*n2*n3).
Expected Auxiliary Space: O(n1*n2*n3).

Constraints:
1<=n1, n2, n3<=100