Single Numbe
来源:互联网 发布:网站流量数据分析 编辑:程序博客网 时间:2024/06/02 06:54
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?
Subscribe to see which companies asked this question
public class Solution { public int singleNumber(int[] nums) { if (nums == null || nums.length < 0) { return 0; } if (nums.length == 0) { return nums[0]; } int flag = nums[0]; for (int i = 1; i < nums.length; i++) { flag ^= nums[i];//异或 } return flag; }}
0 0
- Single Numbe
- [LeetCode]136.Single Numbe
- Happy Numbe
- HDU 1018 big numbe
- 202. Happy Numbe
- LeetCode 9.Palindrome Numbe
- LintCode majority numbe (主元素)
- LeetCpde 246 -- Strobogrammatic Numbe I
- Single
- Single
- MySQL 数据类型 (Text,numbe…
- MySQL 数据类型 (Text,numbe…
- Leetcode之 Find the Duplicate Numbe
- [3]611. Valid Triangle Numbe(Java)
- HDU-1394 Minimum Inversion Numbe…
- Matlab 2012a 获取Numbe…
- leetcode:数学:Excel Sheet Column Numbe(171)
- Single模式
- springmvc 拦截器拦截静态资源
- sublime运行python文件简单配置与安装
- 深入理解React中的上下文this
- SessionID的本质
- ORA-01789: 查询块具有不正确的结果列数
- Single Numbe
- Java IO实现文件的复制
- Linux查看CPU和内存使用情况
- 在微信等浏览器页面吊起拨打电话的功能
- centos 6 下,zephir的安装和使用
- unity3d : failed to initialize unity graphics
- linux下的多线程下载工具 axel
- spring和mybatis整合02
- 直接插入排序