Home

[LeetCode][389] Programming Skills / Find The Difference

Created
2025/02/03 15:44
class Solution: def findTheDifference(self, s: str, t: str) -> str: alphabet_s = [0] * 30 alphabet_t = [0] * 30 s += " " for i in range(len(t)): if s[i] != " ": alphabet_s[ord(s[i]) - 96] += 1 alphabet_t[ord(t[i]) - 96] += 1 else: alphabet_t[ord(t[i]) - 96] += 1 for i in range(30): if alphabet_s[i] < alphabet_t[i]: return chr(i+96)
Python
복사