Getting Runtime Error trying submit C# solution


  • 1
    C

    Has anyone tried submitting a solution in C#?

    Run code button works, but I'm getting Runtime Error on submission at the long "aaaaaaaaaa.." test case.
    I'm wondering if this is an LC bug, or just midnight.

    Can someone try this? This is essentially same as any other Java/C++ solutions I've seen here: gready expand with move:

    public class Solution 
    {
        public string LongestPalindrome(string s) 
        {        
            int length = s.Length;
            
            int istart = 0, iend = 0, maxlen = 1;      
    
            for (int icenter=0; icenter < length-1; icenter++)
            {
                int i = icenter, j = icenter;
                
                while (j+1 < length && s[i]==s[j+1]) { j++; }
                icenter = j;
    
                while (i > 0 && j+1 < length && s[i-1]==s[j+1])  { i--; j++; }
                
                if (j-i+1 > maxlen)
                {
                    istart = i;
                    iend = j;
                    maxlen = j-i+1;
                }        
            }
    
            return s.Substring(istart, maxlen);
        }
    

  • 0
    C

    Nevermind... submitted same code today, and it got Accepted. Got 84% efficiency

    so be mindful, may not be your fault. LC also has bugs/outages.


Log in to reply
 

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