My simple JS Solution


  • 0
    S

    I'm sure there's a more efficient way, but this is concise and understandable:

    var findTheDifference = function(s, t) {
        let sSum = tSum = 0
        for (let i = 0; i < s.length; i++) {
            sSum += s[i].charCodeAt()
            tSum += t[i].charCodeAt()
        }
        tSum += t[t.length - 1].charCodeAt()
        return String.fromCharCode(tSum - sSum)
    };
    

Log in to reply
 

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