Tap here to switch tabs
Problem
Submissions

Problem: Minimum Index Sum of Common Elements

Minimum Index Sum of Common Elements compares two equal-length integer arrays and asks for the smallest sum of the indices of matching values, or -1 when no value appears in both.

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

Minimum Index Sum of Common Elements compares two equal-length integer arrays and asks for the smallest sum of the indices of matching values, or -1 when no value appears in both.

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