Medium
,Array
,DP
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 two numbers nums1[i]
and nums2[j]
such that:
nums1[i]
== nums2[j]
, andNote that a connecting line cannot intersect even at the endpoints (i.e., each number can only belong to one connecting line).
Return the maximum number of connecting lines we can draw in this way.
Example 1:
Example 2:
Example 3:
Constraints:
nums1.length
, nums2.length
<= 500nums1[i]
, nums2[j]
<= 2000讀完題目就覺得超像LCS,快速寫一個遞迴版本立刻TLE…
放上來給大家笑一下
下面這個才會過
MarsgoatMay 11, 2023
上面這個會顯而易見的 Failed,我再想想
skylanlyMay 12, 2023