Longest common subsequence

Give a longest common subsequence.

Examples

Worked example

Input
ABC and AXC
Expected output
AC

Hints and solution

Hint 1

Write down the starting state and walk through one example by hand.

Reveal worked answer

Both strings contain A before C. Their middle letters differ, so no length-three common subsequence exists.

Back to the lesson