边工作边刷题:70天一遍leetcode: day 11-3
生活随笔
收集整理的這篇文章主要介紹了
边工作边刷题:70天一遍leetcode: day 11-3
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Single Number I/II
II的python解是網上抄的,其實可以AC,但是python不會像c++/java那樣自動overflow,而是轉化成long。所以如果有負數的情況會得到一個巨大的正數解,比如
Input:[-2,-2,1,1,-3,1,-3,-3,-4,-2]
Output:4294967292
Expected:-4
class Solution(object):def singleNumber(self, nums):""":type nums: List[int]:rtype: int"""res = 0for i in nums:res = i ^ resreturn res轉載于:https://www.cnblogs.com/absolute/p/5675812.html
總結
以上是生活随笔為你收集整理的边工作边刷题:70天一遍leetcode: day 11-3的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: codeforces 476B.Dre
- 下一篇: ListT please check