2025-08-24 09:34:32 +0000 UTC

Find the Key of the Numbers

Code

class Solution:
    def generateKey(self, num1: int, num2: int, num3: int) -> int:
        res = 0
        cnt = 0
        while num1 > 0 and num2 > 0 and num3 > 0:
            res += min(num1 % 10, num2 % 10, num3 % 10) * (10 ** cnt)
            cnt += 1
            num1 //= 10
            num2 //= 10
            num3 //= 10
        return res