Tap here to switch tabs
Problem
Submissions

Problem: Minimum Absolute Difference Between Two Values

Try to solve the Minimum Absolute Difference Between Two Values problem.

Statement

Given an integer array nums consisting only of the integers 00, 11, and 22, find the minimum absolute difference between the indices i and j such that nums[i] is equal to 11 and nums[j] is equal to 22.

Return the minimum value of ∣i−j∣|i - j| among all such pairs. If the array does not contain both 11 and 22, return −1-1.

Constraints:

  • 1≤1 \leq nums.length ≤100\leq 100

  • 0≤0 \leq nums[i] ≤2\leq 2

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Absolute Difference Between Two Values

Try to solve the Minimum Absolute Difference Between Two Values problem.

Statement

Given an integer array nums consisting only of the integers 00, 11, and 22, find the minimum absolute difference between the indices i and j such that nums[i] is equal to 11 and nums[j] is equal to 22.

Return the minimum value of ∣i−j∣|i - j| among all such pairs. If the array does not contain both 11 and 22, return −1-1.

Constraints:

  • 1≤1 \leq nums.length ≤100\leq 100

  • 0≤0 \leq nums[i] ≤2\leq 2