MCPcopy Create free account
hub / github.com/LjyYano/LeetCode / singleNumber

Method singleNumber

src/main/java/L0136_SingleNumber.java:35–41  ·  view source on GitHub ↗

使用异或运算的特性来解决问题: 1. a ⊕ a = 0(任何数和自己异或等于 0) 2. a ⊕ 0 = a(任何数和 0 异或等于它自己) 3. 异或运算满足交换律和结合律 因此,对数组中所有元素进行异或运算,最终结果就是只出现一次的数字

(int[] nums)

Source from the content-addressed store, hash-verified

source not stored for this graph (policy: none)

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected