当前位置: 代码迷 >> 综合 >> leetcode : Single Number 数组中找出只出现一次的数字
  详细解决方案

leetcode : Single Number 数组中找出只出现一次的数字

热度:43   发布时间:2023-12-07 00:48:21.0

题目描述

 

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?

public class Solution {public int singleNumber(int[] A) {int singleNum=0;for(int i=0;i<A.length;i++){singleNum=singleNum^A[i];}return singleNum;}
}

 

  相关解决方案