C# using ^ solution, simple, clear and fast!


  • 0
    A
    public class Solution {
        public char FindTheDifference(string s, string t) {
            char rst = 'a';
            rst ^= 'a';
            foreach (char ele in s){
                rst ^= ele;
            }
            foreach (char ele in t){
                rst ^= ele;
            }        
            return rst;
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.