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

Commit95bb85f

Browse files
Create 136-Single-Number.java
1 parented259ed commit95bb85f

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