this the the link of instructions it starts page 25 https://drive.google.com/fil
ID: 3886109 • Letter: T
Question
this the the link of instructions it starts page 25
https://drive.google.com/file/d/0B54VYuzeA502cm5lNklsTmdoME0/view?usp=sharing
how can i fix this to get 100 percent. please rewrite the code or fix it
bool prefixAgain(const string& str, int n)
{
int len = str.length();
string prefix = str.substr(0,n);
for(int i = n; i <= n; i++){
if(n + i <= len)
{
if(prefix == str.substr(i, i + n))
return true;
}
}
return false;
}
Explanation / Answer
bool prefixAgain(const string& str, int n)
{
int len = str.length();
string prefix = str.substr(0,n);
for(int i = n; n+i <= len; i++)
{
if(prefix == str.substr(i, i + n))
{
return true;
}
}
return false;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.