Leetcode 389 Find the Difference
来源:互联网 发布:详解进化论知乎 编辑:程序博客网 时间:2024/05/23 01:12
Leetcode 389 Find the Difference
#include <vector>#include <string>using namespace std;class Solution {public: char findTheDifference(string s, string t) { vector<int> lettercount(26,0); for(int i = 0;i < s.length();i ++) { lettercount[s[i] - 'a'] ++; } for(int i = 0; i < t.length();i ++) { lettercount[t[i] - 'a'] --; if(lettercount[t[i] - 'a'] < 0) return t[i]; } } char findTheDifference1(string s, string t) { char c = 0; for(int i = 0;i < s.length();i ++) { c ^= s[i]; } for(int i = 0; i < t.length();i ++) { c ^= t[i]; } return c; } char findTheDifference2(string s, string t) //to learn { char c = 0; for (auto ch : s) c ^= ch; for (auto ch : t) c ^= ch; return c; }};
阅读全文
0 0
- 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
- LeetCode.389 Find the Difference
- Leetcode:Find the Difference
- Find the Difference --LeetCode
- LeetCode Find the Difference
- [LeetCode] Find the Difference
- [Leetcode] Find the Difference
- 375. Guess Number Higher or Lower II
- Leetcode 121 Best Time to Buy and Sell Stock
- 【java】 Dubbo访问有时候访问到,有时候访问不到问题
- Test Mission: Definition, Components and Application
- 修改项目的JDK和WEB版本
- Leetcode 389 Find the Difference
- java练习题2
- 卷积和傅立叶变换
- Leetcode 412 Fizz Buzz
- 正则表达式基本用法
- Redis
- 解密
- PPM图像格式说明
- 矩形面积并