136. Single Number Difficulty: Medium
来源:互联网 发布:最终幻想14 mac 编辑:程序博客网 时间:2024/06/19 05:27
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?
算法分析:
C语言版
int singleNumber(int* nums, int numsSize) { int i, n = nums[0]; for(i = 1; i < numsSize; i++) n ^= nums[i]; return n;}
Python版
class Solution(object): def singleNumber(self, nums): """ :type nums: List[int] :rtype: int """ n = nums[0] for t in nums[1:]: n ^= t return n
阅读全文
0 0
- 136. Single Number Difficulty: Medium
- Leet Code OJ 136. Single Number [Difficulty: Medium]
- Leet Code OJ 260. Single Number III [Difficulty: Medium]
- 136. Single Number [medium] (Python)
- 136.LeetCode Single Number(medium)[数组 单数]
- Leetcode 136. Single Number (Medium) (cpp)
- [Medium]Single Number III
- [LeetCode] 136--Single Number --Medium--
- Medium 136题 Single Number
- 540. Single Element in a Sorted Array Difficulty:Medium
- Leet Code OJ 268. Missing Number [Difficulty: Medium]
- [Leetcode 136, Medium] Single Number I
- [Leetcode 137, Medium] Single Number II
- 【LeetCode】(137)Single Number II(Medium)
- 【LeetCode】(260)Single Number III(Medium)
- [LeetCode] 137--Single Number II --Medium--
- 260. Single Number III [medium] (Python)
- Leetcode 137. Single Number II (Medium) (cpp)
- 字符串算法——查找数组第K个最大值( Kth Largest Element in an Array)
- 全卷积网络FCN详解
- Python学习之路---Python 列表
- Java 8时间和日期API 20例
- Java-day05数组
- 136. Single Number Difficulty: Medium
- String类split方法
- Qt(Ubuntu)静态编译无法显示图片
- L1-015. 跟奥巴马一起画方块
- tablayout与viewpager的结合
- UVa 10881
- HDU 5213 Lucky 容斥+莫队
- 【JSON】GSON工具介绍
- Android APP启动时出现白屏或者黑屏怎么办?