Skip to content

Commit 54955eb

Browse files
folder structure formatted
1 parent 04507dd commit 54955eb

11 files changed

+32
-9
lines changed
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# [May 31 Day Coding Challenge](https://leetcode.com/explore/challenge/card/may-leetcoding-challenge/)
2+

Java/single-number.java

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Given a non-empty array of integers, every element appears twice except for
3+
* one. Find that single one.
4+
*
5+
* Note:
6+
*
7+
* Your algorithm should have a linear runtime complexity. Could you implement
8+
* it without using extra memory?
9+
*
10+
* Example 1:
11+
*
12+
* Input: [2,2,1] Output: 1
13+
*
14+
* Example 2:
15+
*
16+
* Input: [4,1,2,1,2] Output: 4
17+
*
18+
*/
19+
class Solution {
20+
public int singleNumber(int[] nums) {
21+
int aloneNum = nums[0];
22+
23+
for (int i = 1; i < nums.length; i++) {
24+
aloneNum ^= nums[i];
25+
// System.out.println(aloneNum);
26+
}
27+
28+
return aloneNum;
29+
}
30+
}

May-LeetCoding-Challenge/README.md

-9
This file was deleted.
-175 KB
Binary file not shown.
-150 KB
Binary file not shown.
-115 KB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)