LeetCode
来源:互联网 发布:淘宝查号131458 编辑:程序博客网 时间:2024/06/06 14:24
解题代码:
classSolution {
public:
char findTheDifference(string s, string t){
char result;
for(int i=0;i<t.size();i++){
for(int j=0;j<s.size();j++){
if(t[i]==s[j]){
t[i]='0';
s[j]='0';
}
}
if(t[i]!='0')
return t[i];
}
}
};
解题思路:
题目要求字符串s和t中不相同的字符,我采用的方法是把t中每个字符与s中逐个相比,若相同则把s中这一字符替换成‘0’;并进行下一个字符的比较;若找不到相同,则表明这个字符就是多出来的字符。
0 0
- leetcode
- [leetcode]
- LeetCode
- leetcode
- leetcode
- leetcode:
- leetcode:
- LeetCode
- leetcode
- LEETCODE
- leetcode
- leetCode
- leetcode
- [leetcode]
- LeetCode
- leetcode
- leetcode:
- leetcode
- 每一个程序员都应该知道的高并发处理技巧、创业公司如何解决高并发问题、互联网高并发问题解决思路、caoz大神多年经验总结分享
- 【BZOJ 4569】【SCOI 2016】萌萌哒
- 这可能是我在CSDN的最后一篇文章了...
- 字符串右移
- 基于Qt搭建ROS开发环境
- LeetCode
- nodejs操作mongodb数据库
- 用tensorflow实现usps和mnist数据集的迁移学习
- JavaFile类基本用法大全
- 最小K个数之和
- 工具类:将毫秒转换成天时分秒
- Linux下alias设置永久有效
- 欢迎使用CSDN-markdown编辑器
- Cogs 1714. [POJ1741][男人八题]树上的点对(点分治)