#3741
Minimum Distance Between Three Equal Elements II
specialist · 645 · lc medium +30 · 65.2% accepted · 56 likes · top 69%
Description
Given an integer array nums, return the minimum value of abs(i - j) + abs(j - k) + abs(k - i) over all triples (i, j, k) of distinct indices with nums[i] == nums[j] == nums[k], or -1 if no such triple exists.
Code
1
2
3