using System.Collections.Generic;
public static Tuple<int, int> FindTwoSum(IList<int> list, int sum)
var l = list as List<int>;
if (l == null || l.Count < 2)
var distinctList = l.Distinct().ToList();
for (int i = 0; i < distinctList.Count; i++)
int diff = sum - distinctList[i];
int index = distinctList.BinarySearch(i + 1, distinctList.Count - (i + 1), diff, null);
return new Tuple<int, int>(l.FindIndex(item => item == distinctList[i]), l.FindIndex(item => item == distinctList[index]));
public static void Main(string[] args)
Tuple<int, int> indices = FindTwoSum(new List<int>() { 10, 12, 0, 1,1,3,3, 5, 7, 9 }, 8);
Console.WriteLine("not found");
Console.WriteLine(indices.Item1 + " " + indices.Item2);