LeetCode solutions

3830. Find Closest Person

My accepted Python solution to LeetCode problem 3830, Find Closest Person, running in 0ms.

  • Difficulty: Easy
  • Python
  • Runtime 0ms
  • Memory 17.1MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 0ms, memory 17.1MB, accepted 2025-12-30.

python
class Solution:
    def findClosest(self, x: int, y: int, z: int) -> int:
        d1 = abs(x - z)
        d2 = abs(y - z)
        if d1 < d2:
            return 1
        elif d2 < d1:
            return 2
        return 0

Source