Tap here to switch tabs
Problem
Submissions

Problem: Uncrossed Lines

med
30 min
Try to solve the Uncrossed Lines problem.

Statement

You are given two integer arrays nums1 and nums2.

The numbers of nums1 and nums2 are placed on two separate horizontal lines in their original order. You may draw connecting lines between elements where a line connects nums1[i] and nums2[j] such that:

  • nums1[i] == nums2[j]

  • The line does not intersect with any other drawn line.

Return the maximum number of uncrossed connecting lines that can be drawn.

Note: A connecting line cannot intersect another line at any point, including its endpoints, which means each position in nums1 and nums2 can be connected at most once.

Constraints:

  • 1≤1 \leq nums1.length, nums2.length ≤500\leq 500

  • 1≤1 \leq nums1[i], nums2[j] ≤2000\leq 2000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Uncrossed Lines

med
30 min
Try to solve the Uncrossed Lines problem.

Statement

You are given two integer arrays nums1 and nums2.

The numbers of nums1 and nums2 are placed on two separate horizontal lines in their original order. You may draw connecting lines between elements where a line connects nums1[i] and nums2[j] such that:

  • nums1[i] == nums2[j]

  • The line does not intersect with any other drawn line.

Return the maximum number of uncrossed connecting lines that can be drawn.

Note: A connecting line cannot intersect another line at any point, including its endpoints, which means each position in nums1 and nums2 can be connected at most once.

Constraints:

  • 1≤1 \leq nums1.length, nums2.length ≤500\leq 500

  • 1≤1 \leq nums1[i], nums2[j] ≤2000\leq 2000