Given an integer array nums (0-indexed) and two integers target and start, find an index i such that nums[i] == target and abs(i - start) is minimized. Note that&nbsp;abs(x)&nbsp;is the absolute value of x.

Return abs(i - start).

It is guaranteed that target exists in nums.

&nbsp;
Example 1:

Input: nums = [1,2,3,4,5], target = 5, start = 3
Output: 1
Explanation: nums[4] = 5 is the only value equal to target, so the answer is abs(4 - 3) = 1.


Example 2:

Input: nums = [1], target = 1, start = 0
Output: 0
Explanation: nums[0] = 1 is the only value equal to target, so the answer is abs(0 - 0) = 0.


Example 3:

Input: nums = [1,1,1,1,1,1,1,1,1,1], target = 1, start = 0
Output: 0
Explanation: Every value of nums is 1, but nums[0] minimizes abs(i - start), which is abs(0 - 0) = 0.


&nbsp;
Constraints:


	1 &lt;= nums.length &lt;= 1000
	1 &lt;= nums[i] &lt;= 104
	0 &lt;= start &lt; nums.length
	target is in nums.


class Solution:
    def getMinDistance(self, nums: List[int], target: int, start: int) -> int:
        if nums[start] == target: return 0
        left, right = start-1, start+1
        N = len(nums)
        while True:
            if left >=0 and nums[left] == target:
                return start - left
            if right < N and nums[right] == target:
                return right - start
            left -= 1
            right += 1
class Solution {
    public int getMinDistance(int[] nums, int target, int start) {
        int ans = Integer.MAX_VALUE;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == target) {
                ans = Math.min(ans, Math.abs(i - start));
            }
        }
        return ans;
    }
}
class Solution{
public:
    int getMinDistance(vector<int>& nums, int target, int start){
        int ans = INT_MAX;
        for(int i = 0; i < nums.size(); i++){
            int temp = 0;
            if (nums[i] == target){
                temp = abs(i - start);
                if (temp < ans){
                    ans = temp;
                }
            }
        }
        return ans;
    }
};
var getMinDistance = function(nums, target, start) {
    let min = Infinity;
    for(let i=nums.indexOf(target);i<nums.length;i++){
        if(nums[i]===target){
            if(Math.abs(i-start)<min) min = Math.abs(i-start);
        }
    }
    return min;
};
Minimum Distance to the Target Element