Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

rpg

rpg rpg

Niner since 2004

  • Gary Daniels and Evan Goldring - Mock whiteboard problem

    Here is a recursive version of palindrome checker

    public bool IsPalindrome(string s)
    {
       if(s==null) return false; 
       s = s.Replace(" ", "");
       if(s.Length == 0) return false;
       return IsPalindrome(s, 0, s.length);
    }

    private bool IsPalindrome(String s, int first, int last) 
    {
       if(first >= (s.Length / 2)) return true; 
       if ( s[first] == s[last])
        return IsPalindrome(s, ++first, --last);
       else
        return false;
    }

  • Gary Daniels and Evan Goldring - Mock whiteboard problem

    Here is the function that checks for palindrome

    public bool IsPalindrome(string s)
      {
       //Parameter validations
       if(s==null||s==string.Empty) return false ;
       //replace whitespaces
       s = s.Replace(" ", "").ToLower();
       int len = s.Length ;
       Stack ds = new Stack(len);   
       for(int i=0;i<len;i++)
        ds.Push(s[i]);
       for(int i=0;i<len;i++)
       {
        char c = (char)ds.Pop();
        if(c == s[i])
         continue;
        else
         return false;
       }
       return true ;
      }