Wow, exactly what I needed! Also, for those who don't know, XOR operation is both associative and commutative, therefore, the sequence of characters will not affect the output.
Did it myself today!! using the hashing. char findTheDifference(string s, string t) { vector mp(27,0); char ans = '0'; // we first initialise the vector array with the freq of the characters of string s; for(auto i=0;i
Wow, exactly what I needed! Also, for those who don't know, XOR operation is both associative and commutative, therefore, the sequence of characters will not affect the output.
Thank you for the daily problems ! Love the multiple approaches.
Liked the xor approach
Bro youre the best ,We really appreciate your efforts ,Thankyou
The last solution is just mind blowing!
ikr! I never knew we could do this with bits
thank you so much for solving the daily challenges !!
Thank you for your efforts it's very helpful
how is problem solving going for you? still solving? :)
Ya are a legend!!! , thanks!!!
XOR approach ❤
return chr(sum([ord(ch) for ch in t]) - sum([ord(ch) for ch in s])) # one liner
return chr(reduce(lambda x, y: x ^ y, [ord(ch) for ch in (t+s)])) # one liner using reduce and XOR 🤔
same, good one
Did it myself today!!
using the hashing.
char findTheDifference(string s, string t) {
vector mp(27,0);
char ans = '0';
// we first initialise the vector array with the freq of the characters of string s;
for(auto i=0;i
my solution:
if s == "":
return t
for i in s:
t = t.replace(i, "", 1)
return t
i think it is easier and more readable 🙃🙃
The real deal is learning various ways than just for loops and stuff. the XOR method and ascii value calcs are pretty cool
❤❤
I wrote like this
class Solution {
public:
char findTheDifference(string s, string t) {
vectorvecS(26,0);
vectorvecT(26,0);
for(int i=0;i
what a crappy example they gave
Another one liner
return set(t).difference(set(s)).pop()