Leetcode 389. Find the Difference (Easy) (cpp)
来源:互联网 发布:会计事务所审计软件 编辑:程序博客网 时间:2024/04/30 18:49
Leetcode 389. Find the Difference (Easy) (cpp)
Tag: Hash Table, Bit Manipulation
Difficulty: Easy
/*389. Find the Difference (Easy)Given two strings s and t which consist of only lowercase letters.String t is generated by random shuffling string s and then add one more letter at a random position.Find the letter that was added in t.Example:Input:s = "abcd"t = "abcde"Output:eExplanation:'e' is the letter that was added.*/class Solution {public: char findTheDifference(string s, string t) { char result = 0; for (char c : s) { result ^= c; } for (char c : t) { result ^= c; } return result; }};class Solution {public: char findTheDifference(string s, string t) { unordered_map<char, int> mapping; for (char c : s) { mapping[c] += 1; } for (char c : t) { mapping[c] -= 1; if (mapping[c] == -1) { return c; } } return ' '; }};
0 0
- Leetcode 389. Find the Difference (Easy) (cpp)
- 389.leetcode Find the Difference(easy)[字符串处理]
- 【leetcode】【Easy】【389. Find the Difference】【string】【bit manipulation】
- 389. Find the Difference [easy] (Python)
- 389. Find the Difference 难度:easy
- LeetCode : 389. Find the Difference
- Leetcode 389. Find the Difference
- 【leetcode】389. Find the Difference
- Leetcode 389. Find the Difference
- LeetCode 389. Find the Difference
- LeetCode 389. Find the Difference
- [LeetCode]389. Find the Difference
- [LeetCode]--389. Find the Difference
- leetcode 389. Find the Difference
- LeetCode 389. Find the Difference
- LeetCode 389. Find the Difference
- leetcode 389. Find the Difference
- 389.[LeetCode]Find the Difference
- hdu5023 A Corrupt Mayor's Performance Art(线段树+区间更新)
- pci acpi note 2
- Python中幽灵般的yield
- Hibernate中所需要的各jar的作用
- 写给新手程序员的一封信
- Leetcode 389. Find the Difference (Easy) (cpp)
- DFS-PATA-1004. Counting Leaves (30)
- 文章标题
- Studio部署文件时出现错误 ADB enabled
- Resolve VC++ 2015 D8016 Error
- getchar()用法
- 查找组成一个偶数最接近的两个素数
- LightOJ 1092 Lighted Panels 状压DP
- 1305: [CQOI2009]dance跳舞