Find the longest string | GFG POTD | Easy Explanation | Hindi | Hashing | String

preview_player
Показать описание
gfg potd
gfg potd today
gfg problem of the day

#dsa #datastructures #algorithm #gfg #potd #coding #tree #hashing #strings
Рекомендации по теме
Комментарии
Автор

Thanks for explaining this problem in easiest way.

suman_kashyap
Автор

Initially when I saw the tags then I thought i haven't done the advance DS so will not be able to solve the problem but when i saw your solution it's so easy
Great approach and explanation 🙌

sumit
Автор

Awesome logic, I have also applied it.

vivekanandpandey
Автор

Really nice explanation! Keep posting 👍

himanshumaurya
Автор

string longestString(vector<string> &words)
{
// code here
map<string, int> mp;
for(int i=0;i<words.size();++i){
mp[words[i]]++;
}
string ans="";
for(int i=0;i<words.size();++i){
int j=0;
string temp="";
string it=words[i];
int flag=0;
for(j=0;j<it.size();++j){
temp=temp+it[j];
if(mp.find(temp)==mp.end()){
flag=1;
break;
}
if(ans.size()<=temp.size() && flag==0){
if(ans.size()==temp.size()){
ans=min(ans, temp);
}
else{
ans=temp;
}
}
}
}
return ans;
}

shreyank
Автор

hello.i got to know that ..gfg gives goodies, for the streaks...is it right, , , have you got any..

theeurekachannel