Removing Substrings from List I have a list of palindromes 

List&lt;string&gt; palindromes = new List&lt;string&gt;() 
{
    hijkllkjih,
    ijkllkji,
    jkllkj,
    kllk,
    ll,
    defggfed,
    efggfe,
    fggf,
    gg,
    abccba, 
    bccb,
    cc,
    qrrq, 
    rr,
    mnnm, 
    nn,
    pop, 
    o,
    s, 
    q,
    r
};


But I want to remove palindromes that are substring of other palindromes. So, the list would become

List&lt;string&gt; palindromes = new List&lt;string&gt;() 
{
    hijkllkjih,
    defggfed,
    abccba, 
    qrrq, 
    mnnm, 
    pop, 
    s, 
    q,
    r
};


To do this I have written the following code 

List&lt;int&gt; indexList = new List&lt;int&gt;();
for (int i = 0; i &lt; palindromes.Count; ++i)
{
    if (indexList.Contains(i))
        continue;

    string tmp = palindromes[i];
    for (int j = 0; j &lt; palindromes.Count; ++j)
    {
        if (i == j 
            || indexList.Contains(j) 
            || palindromes[j].Length &gt; palindromes[i].Length)
            continue;

        if (tmp.Contains(palindromes[j]))
            indexList.Add(j);
    }
}

foreach (var index in indexList.OrderByDescending(l =&gt; l))
    palindromes.RemoveAt(index);


Can this be improved?
You can simplify your code to this:

var palindromesCopy = palindromes.ToList();
palindromes.RemoveAll(x =&gt; palindromesCopy.Any(y =&gt; x != y &amp;&amp;
                                               y.Contains(x)));


If you want to remove duplicated strings as said by @MoonKnight in comments, just call Distinct on palindromes after removing.