SSS: Simple Swift Solution ★★
\nfunc nearestValidPoint(_ x: Int, _ y: Int, _ points: [[Int]]) -> Int {\n\tvar (result, dMin) = (-1, Int.max)\n\n\tfor (i, point) in points.enumerated() {\n\t\
```\nfunc nearestValidPoint(_ x: Int, _ y: Int, _ points: [[Int]]) -> Int {\n\tvar (result, dMin) = (-1, Int.max)\n\n\tfor (i, point) in points.enumerated() {\n\t\tlet x1 = point[0], y1 = point[1]\n\t\tguard x == x1 || y == y1 else { continue }\n\t\tlet d = abs(x - x1) + abs( y - y1)\n\t\tif d < dMin {\n\t\t\tdMin = d\n\t\t\tresult = i\n\t\t}\n\t}\n\n\treturn result\n}\n```\n\nor\n\n```\nfunc nearestValidPoint(_ x: Int, _ y: Int, _ points: [[Int]]) -> Int {\n    let notFoundIndexValue = -1\n    var (result, mdMin) = (notFoundIndexValue, 0)\n\n    for (i, point) in points.enumerated() {\n        let (x1, y1) = (point[0], point[1])\n        guard x == x1 || y == y1 else { continue }\n        let md = abs(x - x1) + abs(y - y1)\n        guard result != notFoundIndexValue else {\n            (result, mdMin) = (i, md)\n            continue\n        }\n        if md < mdMin { (result, mdMin) = (i, md) }\n    }\n\n    return result\n}\n```
['Swift']