The longest common subsequence (LCS) problem asks, for two given sequences, for the longest sequence that is a subsequence of both.
For example, the LCS of [1, 2, 3] and [1, 3, 2] is [1, 2] or [1, 3], and its size is 2.
You are given two sequences A and B in which every integer from 1 to N appears exactly once. Write a program that computes the size of their LCS.