当前位置:网站首页>Leetcode topic resolution single number
Leetcode topic resolution single number
2022-06-23 06:17:00 【ruochen】
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?
For the appearance of 2 Secondary figures , Using XOR . because “ Dissimilarity is 1”, So a digital XOR itself is 0, and 0 Exclusive or 0 Still 0, A number is XOR 0 Still this number .
0 ^ 0 = 0 n ^ 0 = n n ^ n = 0
public int singleNumber(int[] nums) {
int n = 0;
for (int i : nums) {
n ^= i;
}
return n;
}边栏推荐
- Runc symbolic link mount and container escape vulnerability alert (cve-2021-30465)
- Pyinstaller package exe setting icon is not displayed
- 【Leetcode】431. Encode n-ary tree to binary tree (difficult)
- SQL表名与函数名相同导致SQL语句错误。
- jvm-05.垃圾回收
- Work accumulation - judge whether GPS is on
- mongodb 4.x绑定多个ip启动报错
- Pat class B 1024 scientific notation C language
- [DaVinci developer topic] -42- how to generate template and header files of APP SWC
- Basic calculator for leetcode topic analysis
猜你喜欢
随机推荐
Tcp/ip explanation (version 2) notes / 3 link layer / 3.3 full duplex, energy saving, automatic negotiation mechanism, 802.1x flow control / 3.3.3 link layer flow control
Possible pits in mongodb project
WordPress contact form entries cross cross site scripting attack
jvm-04.对象的内存布局
Implementation of linear list linked list structure
Add and multiply two polynomials using linked list
Wireshark TS | 视频 APP 无法播放问题
Day_12 传智健康项目-JasperReports
【Vivado那些事儿】XilinxCEDStore介绍
Pat class B 1016 C language
Causes and methods of exe flash back
Pat class B 1009 C language
基于T5L1的小型PLC设计方案
[vivado] xilinxcedstore introduction
Find the number of nodes in the widest layer of a binary tree
Learning Tai Chi Maker - esp8226 (11) distribution network with WiFi manager Library
Basic calculator II for leetcode topic analysis
Microsoft interview question: creases in origami printing
(1)基础学习——vim编辑器常用快捷操作命令
Kotlin Android simple activity jump, simple combination of handler and thread








![[vivado] xilinxcedstore introduction](/img/c7/4f203d125ddb18378398a7eaeffaf5.png)