Skip to content

Commit 41077f0

Browse files
authored
Create find-the-difference.cpp
1 parent 0e4fa78 commit 41077f0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

C++/find-the-difference.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Time: O(n)
2+
// Space: O(1)
3+
4+
class Solution {
5+
public:
6+
char findTheDifference(string s, string t) {
7+
return accumulate(s.cbegin(), s.cend(), 0, std::bit_xor<int>()) ^
8+
accumulate(t.cbegin(), t.cend(), 0, std::bit_xor<int>());
9+
}
10+
};

0 commit comments

Comments
 (0)