------
## 最终结论
```python
def max_uncrossed_lines(A, B):
    # Create a 2D dp array with dimensions (len(A)+1) x (len(B)+1)
    dp = [[0] * (len(B) + 1) for _ in range(len(A) + 1)]
    
    # Fill the dp array based on the conditions described
    for i in range(1, len(A) + 1):
        for j in range(1, len(B) + 1):
            if A[i - 1] == B[j - 1]:
                dp[i][j] = dp[i - 1][j - 1] + 1
            else:
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
    
    # The result is found in the bottom-right corner of the dp array
    return dp[len(A)][len(B)]

# Example usage:
print(max_uncrossed_lines([1,4,2], [1,2,4]))         # Output: 2
print(max_uncrossed_lines([2,5,1,2,5], [10,5,2,1,5,2])) # Output: 3
print(max_uncrossed_lines([1,3,7,1,7,5], [1,9,2,5,1])) # Output: 2
```