Given an array of integers, return indices of the two numbers such this they add to a specific target.
You may assume this each input would have exactly one solution.
Example:
Given nums = [2, 7, one], target = 9,
because Nums[0] + nums[1] = 2 + 7 = 9, return
[0, 1].
Using System;
Using System.Collections;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using System.Threading.Tasks; Namespace Twosum {class Program {static void Main (string[] args) {program p = new P
Rogram ();
int[] test = new int[] {2, 5, 7, 11};
int targetnum = 9;
Int[] result = P.getindex (test, targetnum);
Console.WriteLine (result[0]+ "" +result[1]); Public int[] GetIndex (int[] array, int target) {dictionary<int,int> symbol = new Dic
Tionary<int,int> ();
int[] res = new INT[2]; for (int i=0;i<array. length;i++) {symbol.
ADD (Array[i], i); for (int j=0;j<array.
length;j++) {int t = target-array[j];
int F; if (symbol.
ContainsKey (t) && symbol[t]!=j) { Res[0] = j;
RES[1] = symbol[t];
Break
} return res;
}
}
}