why my code is Runtime error


  • 0
    F

    class Solution {
    public:
    string longestPalindrome(string s) {
    bool dj;
    int p,o;
    string k="";
    for(int i=0;i<s.size();i++){
    for(int j=i;j<s.size();j++)
    { p=j;
    o=i;
    dj=true;
    while(p>=o)
    {
    if(s[p]==s[o])
    {
    p--;
    o++;
    }
    if(s[p]!=s[o]){
    dj=false;
    break;}
    }
    if(dj==true){
    k=((k.size()<j-i+1)?s.substr(i,j-i+1):k);}
    }}
    return k;
    }
    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.