Kotlin Fast and Easy Solution || 488ms, faster than 92.59%
\nclass Solution {\n    fun nearestValidPoint(x: Int, y: Int, points: Array<IntArray>): Int {\n        var min = Int.MAX_VALUE\n        var index = -1\n        
```\nclass Solution {\n    fun nearestValidPoint(x: Int, y: Int, points: Array<IntArray>): Int {\n        var min = Int.MAX_VALUE\n        var index = -1\n        for (ix in points.indices) {\n            val i = points[ix]\n            if (i[0] != x && i[1] != y) continue // the point is not "valid"\n            val dist = Math.abs(i[0] - x) + Math.abs(i[1] - y)\n            if (dist < min) { // update min and index\n                min = dist\n                index = ix\n            }\n        }\n        return index // done\n    }\n}\n```
['Kotlin']