add max_distance in leetcode