Given a non-empty array of integers, every element appears twice except for one. Find that single one.java
Note:git
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?github
Example 1:app
Input: [2,2,1] Output: 1
Example 2:code
Input: [4,1,2,1,2] Output: 4
最開始咱們使用map:blog
還有就是能夠排序後比較,排序可能就不是線性的啦排序
而後看看大神是怎麼寫的:ip
源碼:https://github.com/woshiyexinjie/leetcode-xin/tree/master/src/main/java/com/helloxin/leetcode/algorithmselement
leetcode:https://leetcode.com/problems/single-number/description/leetcode
有什麼討論的內容,能夠加我公衆號: