Samsung Research America Interview Question

Coding: Array problem to find max distance amongst elements based on some criteria