Time limit exceeded when list with large number of elements used?
<p>Function fails performance test when run with a large number of elements: Time limit exceeded .
    How to pass Performance Test ?</p>

<pre><code> //Function finds indices of two elements whose sum is equal to as passed in the parameter
 public static Tuple&lt;int, int&gt; FindTwoSum(IList&lt;int&gt; list, int sum)
 {
     for (int i = 0; i &lt; list.Count; i++)
     {
         int sum2 = sum - list[i];
         int index = list.IndexOf(sum2);
         if (index &gt; 0 )
         {
             return new Tuple&lt;int, int&gt;(i, index);
         }
     }
     return null;
 }

 //Main function to call FindTwoSum method
 public static void Main(string[] args)
 {
  Tuple&lt;int, int&gt; indices = FindTwoSum(new List&lt;int&gt;() { 1, 3, 5, 7, 9 },12);
  Console.WriteLine(indices.Item1 + " " + indices.Item2);
 }
</code></pre>