leetcode 136 python
来源:互联网 发布:跟团游推荐 知乎 编辑:程序博客网 时间:2024/05/21 05:39
Given an array of integers, every element appears twice except for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
class Solution(object): def singleNumber(self, nums): """ :type nums: List[int] :rtype: int """ s = set(nums) l = list(s) str1 = str(nums) for x in l: if str1.count(str(x)) == 1: return x
class Solution(object): def singleNumber(self, nums): """ :type nums: List[int] :rtype: int """ a = len(nums) if a == 1: return nums[0] sum = 0 for x in nums: sum = sum ^ x return sum
0 0
- leetcode 136 python
- leetcode python
- leetcode python
- leetcode python
- leetcode python
- leetcode python
- leetcode python
- leetcode python
- leetcode python
- leetcode python
- [leetcode: Python]
- 【LeetCode with Python】 Permutations
- Leetcode Python Palindrome Number
- LeetCode-Sort List(Python)
- 【LeetCode with Python】 Subsets
- [leetcode]LRU Cache (python)
- 【leetcode】Reorder List (python)
- 【leetcode】Candy(python)
- Rails使用plain渲染出错的原因
- 阿里云ubuntu系统图形化访问
- 由一道题引出的C++位域问题
- NTU RGB+D: A Large Scale Dataset for 3D Human Activity Analysis
- VC++的工程文件说明
- leetcode 136 python
- Hibernate基本配置及操作
- 理解js中的原型链,prototype与__proto__的关系
- 排序之冒泡排序
- 网页版九宫格拼图游戏
- DHCP协议
- 蓝桥杯 基础练习 Sine之舞 暴力
- JavaScript中的闭包
- 对于数据类型转换的理解