LeetCode solutions

3568. Find the Key of the Numbers

My accepted Python solution to LeetCode problem 3568, Find the Key of the Numbers, running in 4ms.

  • Difficulty: Easy
  • Python
  • Runtime 4ms
  • Memory 17.3MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 4ms, memory 17.3MB, accepted 2025-12-29.

python
class Solution:
    def generateKey(self, num1: int, num2: int, num3: int) -> int:
        # Pad each to 4 digits
        s1 = str(num1).zfill(4)
        s2 = str(num2).zfill(4)
        s3 = str(num3).zfill(4)
        
        # Take min digit at each position
        result = ""
        for i in range(4):
            result += min(s1[i], s2[i], s3[i])
        
        return int(result)

Source