• Welcome to the world's largest Chinese hacker forum

    Welcome to the world's largest Chinese hacker forum, our forum registration is open! You can now register for technical communication with us, this is a free and open to the world of the BBS, we founded the purpose for the study of network security, please don't release business of black/grey, or on the BBS posts, to seek help hacker if violations, we will permanently frozen your IP and account, thank you for your cooperation. Hacker attack and defense cracking or network Security

    business please click here: Creation Security  From CNHACKTEAM

Recommended Posts

6.1:在一个数组中,一个数出现奇数次,其他数出现偶数次。你如何找到并打印这个数字?

方法一:哈希表统计词频,找到奇数。

方法2:异或运算

【4,3,4,2,4,3,1,2,1,1,3,3】,其中1111,22,3333,444。

eor=0

异或1111,22,3333,444

得到0 0 0 4,返回这个奇数4。

1 public static void printoddtimesnum 1(int[]arr){

2 int EOR=0;

3 for(int I=0;长度;i ) {

4 EOR ^=arr

5 }

6 system . out . println(EOR);

7 }

Link to comment
Share on other sites