Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

389. 找不同(简单) - https://leetcode-cn.com/problems/find-the-difference/submissions/ #13

Open
tailgo opened this issue May 22, 2019 · 0 comments
Labels
shanyi 同理 阿狗 阿狗是帅哥呀

Comments

@tailgo
Copy link
Owner

tailgo commented May 22, 2019

把两个字符串一起拼在一起处理,就跟 #6 那道题一样了。

执行用时 : 80 ms, 在Find the Difference的JavaScript提交中击败了98.51% 的用户
内存消耗 : 34.8 MB, 在Find the Difference的JavaScript提交中击败了93.48% 的用户

/**
 * @param {string} s
 * @param {string} t
 * @return {character}
 */
var findTheDifference = function(s, t) {
    var r = 0;
    for (var i = 0; i < s.length; ++i) {
        r = r ^ s[i].codePointAt() ^ t[i].codePointAt();
    }
    return String.fromCharCode(r ^ t[t.length - 1].codePointAt());
};
@tailgo tailgo added the 阿狗 阿狗是帅哥呀 label May 22, 2019
@zhaojianing zhaojianing added the shanyi 同理 label May 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
shanyi 同理 阿狗 阿狗是帅哥呀
Projects
None yet
Development

No branches or pull requests

2 participants