Uncrossed Lines

You are given two integer arrays nums1 and nums2. We write the integers of nums1 and nums2 (in the order they are given) on two separate horizontal lines.

We may draw connecting lines: a straight line connecting nums1[i] and nums2[j] such that nums1[i] == nums2[j], and the line we draw does not intersect any other connecting lines.

Return the maximum number of connecting lines we can draw in this way.

Examples
Input: [[1,4,2],[1,2,4]]
Output: 2
Hints

Uncrossed Lines

You are given two integer arrays `nums1` and `nums2`. We write the integers of `nums1` and `nums2` (in the order they are given) on two separate horizontal lines.