Solutions for Minimum distance between the Places

    • @Geraldpof
    • @Charles, submitted in Python 2, achived 100% score
    def solve(k, arr):
        arr.sort()
        diff = 0
        for i in range(0, len(arr)-k+1):
            current = arr[i+(k-1)] - arr[i]
            if current < diff or not diff:
                diff = current
    
        return diff
    
    
    • @DarrenNop
    • @william, submitted in Python 3, achived 100% score
    def solve(k, arr):
        arr.sort()
        diff = 0
        for i in range(0, len(arr)-k+1):
            current = arr[i+(k-1)] - arr[i]
            if current < diff or not diff:
                diff = current
    
        return diff