Skip to content

Commit 621b9b0

Browse files
add 136
1 parent 8d28b0a commit 621b9b0

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ LeetCode
9696
|0129|[Sum Root to Leaf Numbers](https://leetcode.com/problems/sum-root-to-leaf-numbers/) | c | [c++](./src/0129-Sum-Root-to-Leaf-Numbers/0129.cpp) |[python](./src/0129-Sum-Root-to-Leaf-Numbers/0129.py)|||Medium|
9797
|0130|[Surrounded Regions](https://leetcode.com/problems/surrounded-regions/) | c | [c++](./src/0130-Surrounded-Regions/0130.cpp) |[python](./src/0130-Surrounded-Regions/0130.py)|||Medium|
9898
|0131|[Palindrome Partitioning](https://leetcode.com/problems/palindrome-partitioning/) | c | [c++](./src/0131-Palindrome-Partitioning/0131.cpp) |[python](./src/0131-Palindrome-Partitioning/0131.py)|||Medium|
99+
|0136|[Single Number](https://leetcode.com/problems/single-number/) | c | [c++](./src/0136-Single-Number/0136.cpp) |[python](./src/0136-Single-Number/0136.py)|||Easy|
99100
|0139|[Word Break](https://leetcode.com/problems/word-break/) | c | [c++](./src/0139-Word-Break/0139.cpp) |[python](./src/0139-Word-Break/0139.py)|||Medium|
100101
|0141|[Linked List Cycle](https://leetcode.com/problems/linked-list-cycle/) | c | [c++](./src/0141-Linked-List-Cycle/0141.cpp) |[python](./src/0141-Linked-List-Cycle/0141.py)|||Easy|
101102
|0142|[Linked List Cycle II](https://leetcode.com/problems/linked-list-cycle-ii/) | c | [c++](./src/0142-Linked-List-Cycle-II/0142.cpp) |[python](./src/0142-Linked-List-Cycle-II/0142.py)|||Medium|

src/0136-Single-Number/0136.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <iostream>
2+
#include <vector>
3+
using namespace std;
4+
5+
static int x = []() {std::ios::sync_with_stdio(false); cin.tie(0); return 0; }();
6+
class Solution
7+
{
8+
public:
9+
int singleNumber(vector<int>& nums)
10+
{
11+
int result = 0;
12+
for (auto num : nums) result ^= num;
13+
return result;
14+
}
15+
};
16+
int main(int argc, char const *argv[])
17+
{
18+
vector<int> nums = {2,2,1};
19+
cout << Solution().singleNumber(nums);
20+
return 0;
21+
}

src/0136-Single-Number/0136.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution:
2+
def singleNumber(self, nums):
3+
"""
4+
:type nums: List[int]
5+
:rtype: int
6+
"""
7+
result = 0
8+
for num in nums:
9+
result ^= num
10+
11+
return result
12+
13+
if __name__ == "__main__":
14+
nums = [2,2,1]
15+
print(Solution().singleNumber(nums))

0 commit comments

Comments
 (0)