simple JAVA solution using bit manipulation


  • 1
    G

    public class Solution {
    public char findTheDifference(String s, String t) {
    int tem = 0;
    String st = s + t;
    for(int i = 0; i < st.length(); i++){
    tem = tem ^ ((int)st.charAt(i));
    }
    return (char)tem;
    }
    }


Log in to reply
 

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