MongoDB Interview Question

Longest Common Subsequence optimised solution.