Description
請撰寫一個程式,讓使用者輸入一個數列以及一個整數的目標值,請輸出在這個數列之中,哪兩個索引值內的數值相加為目標值。
Given an array of integersnumsand an integertarget, returnindices of the two numbers such that they add up totarget.
You may assume that each input would haveexactlyone solution, and you may not use thesameelement twice.
You can return the answer in any order.
Input
輸入包含以下兩行:
第一行包含兩個正整數n(4≤n≤10),t代表使用者輸入的數列長度以及目標值。
�(4≤�≤10),�
第二行包含n個正整數,代表數列內的元素。
�
The input contains the following two lines:
The first line contains two positive integers n(10≤n≤30),t represents the length of the sequence input by the user and the target value.
�(10≤�≤30),�
The second line contains n positive integers, representing the elements in the array.
�
Output
請輸出相加為目標值的數的索引值。
Please output the index value of the number that adds up to the target value.
Sample Input 1
4 9
2 7 11 15
Sample Output 1
0 1
Sample Input 2