LeetCode:Find the Difference
来源:互联网 发布:lol安妮舞会公主淘宝 编辑:程序博客网 时间:2024/06/15 08:36
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:
e
Explanation:
‘e’ is the letter that was added.
class Solution {public: char findTheDifference(string s, string t) { char res; char count[256] = {0}; int i; for(int i=0;i<s.length();++i) { count[s[i]]++; } for(i=0;i<t.length();++i) { if(count[t[i]]<=0) break; else count[t[i]]--;//可以达到去重的功能 } return t[i]; }};
0 0
- Leetcode:Find the Difference
- Find the Difference --LeetCode
- LeetCode Find the Difference
- [LeetCode] Find the Difference
- [Leetcode] Find the Difference
- [Leetcode] Find the Difference
- [Leetcode]Find the Difference
- [LeetCode]Find the Difference
- LEETCODE--Find the Difference
- LeetCode:Find the Difference
- LeetCode Find the Difference
- Find the Difference(leetcode)
- LeetCode : 389. Find the Difference
- LeetCode 389 Find the Difference
- Leetcode 389. Find the Difference
- leetcode之Find the Difference
- 【leetcode】389. Find the Difference
- Leetcode 389 Find the Difference
- 高通平台常见的一些错误(持续更新)
- 349. Intersection of Two Arrays
- omnet++ :Cannot run program Error launch simulation for "项目名"
- Git 基本用法上
- Android自定义view
- LeetCode:Find the Difference
- 让一台电脑只能上一个QQ的方法
- 计算机网络:数据链路层03
- JS的取经之路(四)
- Android studio导入Github的项目
- 【maven】mac下maven 配置(转)
- Mac OSX下开机启动守护进程,接受远程命令,从而启动、通信cocoa app
- 构建10G数据中心需要哪些光纤产品?
- wine中解决中文字体问题