Tap here to switch tabs
Problem
Submissions

Problem: Minimum Index Sum of Common Elements

med
30 min
Try to solve the Minimum Index Sum of Common Elements problem.

Statement

Given two integer arrays nums1 and nums2 of equal length, find the minimum index sum i+ji + j such that nums1[i] == nums2[j].

Return the minimum index sum among all common elements. If there are no common elements between nums1 and nums2, return −1-1.

Constraints:

  • 1≤1 \leq nums1.length == nums2.length ≤105\leq 10^5

  • −105≤-10^5 \leq nums1[i], nums2[i] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Index Sum of Common Elements

med
30 min
Try to solve the Minimum Index Sum of Common Elements problem.

Statement

Given two integer arrays nums1 and nums2 of equal length, find the minimum index sum i+ji + j such that nums1[i] == nums2[j].

Return the minimum index sum among all common elements. If there are no common elements between nums1 and nums2, return −1-1.

Constraints:

  • 1≤1 \leq nums1.length == nums2.length ≤105\leq 10^5

  • −105≤-10^5 \leq nums1[i], nums2[i] ≤105\leq 10^5