package
0.0.0-20241220224003-b7cf03a90b2b
Repository: https://github.com/szhou12/leetcode-go.git
Documentation: pkg.go.dev

# README

389. Find the Difference

Solution idea

HashMap / Array of length 26

  • 用 HashMap/Array of Length 26 记录 s中出现的字母,查询t中哪个字母没出现

Time complexity = $O(n)$

XOR - 同性相消

利用异或的性质,X^X = 0,将 s 和 t 依次异或,最终多出来的字符就是最后异或的结果。

Resource