We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 90f3142 commit 57c9d76Copy full SHA for 57c9d76
389. Find the Difference
@@ -0,0 +1,18 @@
1
+So, here also let's say our character are:
2
+s = abc
3
+t = cabx
4
+
5
+if we take XOR of every character. all the n character of s "abc" is similar to n character of t "cab". So, they will cancel each other.
6
+And we left with our answer.
7
8
9
+t = cbax
10
+------------
11
+ans -> x
12
13
+char findTheDifference(string s, string t) {
14
+ char c = 0;
15
+ for(char cs : s) c^=cs; //Xoring all charecter to extract unique one
16
+ for(char ct : t) c^=ct;
17
+ return c;
18
+ }
0 commit comments