Sunday, April 9, 2017

C# program to check whether a string is palindromic

 public static bool isPalindromic(string s)  
           {  
                for (int i = 0, j = s.Length - 1; i < j; i++, j--)  
                {  
                     if (s[i] != s[j])  
                     {  
                          return false;  
                     }  
                }  
                return true;  
           }  
Time complexity: O(n) Space complexity: O(1)