Re: [閒聊] 每日LeetCode已回收

看板Marginalman作者 (史萊哲林的優等生)時間2年前 (2023/09/26 16:12), 編輯推噓2(200)
留言2則, 2人參與, 2年前最新討論串420/719 (看更多)
※ 引述《Rushia (みけねこ的鼻屎)》之銘言: : https://leetcode.com/problems/find-the-difference/description : 389. Find the Difference : 給你一個字串 s 和 t,t 是 s 字串字元亂序並加上一個字元組成的,返回這個被加上 : 的字元。 思路: 用XOR 因為(a⊕a)⊕(b⊕b)⊕c=0⊕0⊕c=c impl Solution { pub fn find_the_difference(s: String, t: String) -> char { let mut result = 0u8; for c in s.bytes() { result ^= c; } for c in t.bytes() { result ^= c; } result as char } } -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 60.251.123.162 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1695715961.A.8ED.html

09/26 16:18, 2年前 , 1F
大師
09/26 16:18, 1F

09/26 16:38, 2年前 , 2F
大師
09/26 16:38, 2F
文章代碼(AID): #1b4f9vZj (Marginalman)
討論串 (同標題文章)
文章代碼(AID): #1b4f9vZj (Marginalman)