Swift Solution:
public func solution(inout A : [Int]) -> Int {
// Return itself if array only contains 1 element
if (A.count == 1) { return A[0] }
var oe = 0
//Since only one odd integer in the array
//so using Xor will balance all the pair numbers except the odd integer
for i in 0 ..< A.count { oe ^= A[i] }
return oe
}
网友评论