#K8191. Shortest Common Supersequence
Shortest Common Supersequence
Shortest Common Supersequence
Given two strings ( s_1 ) and ( s_2 ), your task is to find the length of the shortest common supersequence (SCS). A supersequence of a string is a sequence that contains the string as a subsequence. The shortest common supersequence of ( s_1 ) and ( s_2 ) is the shortest string that has both ( s_1 ) and ( s_2 ) as subsequences. It can be computed using the formula: [ SCS = |s_1| + |s_2| - LCS(s_1,s_2), ] where ( LCS(s_1,s_2) ) is the length of the longest common subsequence of ( s_1 ) and ( s_2 ).
inputFormat
The input consists of two lines. The first line contains the string ( s_1 ) and the second line contains the string ( s_2 ).
outputFormat
Output a single integer which is the length of the shortest common supersequence of the two input strings.## sample
geek
eke
5