今天上午leetcode的比赛,第一道题是识别两个字符串s与t中,t中存在而s中不存在的字符,并返回
以下是我的答案
class Solution{
public:
char findTheDifference(string s, string t){
for (int i = 0; i < t.size(); i++)
{
if (s.find(t[i])==-1)
return t[i];
}
return NULL;
}
想请问各位大神,这段代码中是否有明显错误,以及其中的不足之处
原问题:
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.
#