Problem 3880 · Easy

Minimum Absolute Difference Between Two Values

nums holds only 1s and 2s. Find the smallest index distance between a 1 and a 2; return -1 when one of them is missing.

Open the interactive visualisation