Given two strings, find the length of the longest common subsequence (LCS).

Example

```
A B LCS Length
"ABCD" "EDCA" "A" 1
"ABCD" "EACB" "AC" 2
```

I got Time Limit Exceeded for the following simple recursive solution.

The following uses dynamic programming and follows the algorithm described in this article. This solution is accepted.