Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

palindromic substrings

	public static List<string> SubString(String str)
    {
    	var list = new List<string>();
        for (int i = 0; i < str.Length; i++)
        {
            for (int j = 1; j <= str.Length - i; j++)
            {
                var temp = str.Substring(i, j);
                if(temp==ReverseString(temp))
                {
                    list.Add(temp);
                }
            }
        }
        
        return list;
    }
    public static string ReverseString(string s)
    {
        char[] arr = s.ToCharArray();
        Array.Reverse(arr);
        return new string(arr);
    }
 
PREVIOUS NEXT
Tagged: #palindromic #substrings
ADD COMMENT
Topic
Name
2+5 =