Problem : https://leetcode.com/problems/find-the-difference/
Use hash table to find the difference:
class Solution:
def findTheDifference(self, s: str, t: str) -> str:
counterS = Counter(s)
counterT = Counter(t)
for k, v in counterT.items():
if counterS[k] != v:
return k
No comments:
Post a Comment