using System;
using System.Collections.Generic;
public class Program
{
private static int[] twoSum(int[] array, int target) {
IDictionary<int, int> hmap = new Dictionary<int, int>();
for (int i = 0; i < array.Length; i++) {
int complement = target - array[i];
if (hmap.ContainsKey(complement)) {
return new int[] {hmap[complement], i};
}
else {
hmap[array[i]] = i;
}
}
return new int[] {};
}
public static void Main(string[] args)
{
int[] array = new int[] {1, 5, 7, 6, 4, 3, 2};
int target = 9;
int[] indexes = twoSum(array, target);
if (indexes.Length == 2) {
Console.WriteLine(indexes[0] + " " + indexes[1]);
}
else {
Console.WriteLine("Not found");
}
}
}
/*
run:
1 4
*/