Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfe08748

Browse files
authored
Merge pull requestneetcode-gh#309 from SharmaTushar1/patch-6
Create 136-Single-Number.java
2 parents7f1d352 +95bb85f commitfe08748

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

‎java/136-Single-Number.java‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//We can use xor operation as it cancel out itself (i.e. only when values are different in binary representation then give output). See how xor operation works if confused.
2+
classSolution {
3+
publicintsingleNumber(int[]nums) {
4+
intans =nums[0];
5+
for (inti =1;i<nums.length;i++)
6+
ans ^=nums[i];
7+
returnans;
8+
}
9+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp