給定一個整數目標值(稱為target)、一個正整數,代表陣列長度(稱為 listLength),和一個整數陣列(稱為numberArray),請判斷整數陣列(numberArray)中哪兩個整數相加會得到目標值(target),並將兩數輸出。
Note:
整數陣列 numberArray 不一定由小到大排列
e.g.
(o) 1 2 3 4 5
(o) 5 4 3 2 1
(o) 4 2 1 5 3
陣列中的數字可能重複出現
需考慮的情況:
無解
一組解
多組解
Sample IO
無解
Input:
10
1 2 3 4 5
Output:
No match answer.
一組解
Input:
9
1 2 3 4 5
Output:
4 5
*不重複輸出相同組合 ((4, 5), (5, 4))
多組解
Input:
6
1 2 3 4 5
Output:
1 5
2 4
*不重複輸出相同組合 ((1, 5), (5, 1) / (2, 4), (4, 2))
一個目標值整數*target,一個正整數*listLength,ㄧ個整數陣列*numberArray(陣列長度為 listLength,即為陣列內共有 listLength 個整數)
Note:
-2147483648 <= *target <= 2147483647
0 < *listLength < 20
-1073741824 <= *numberArray[i] <= 1073741823
輸出比須符合以下格式:
無解:
No match answer.
有一組解:
*n1 *n5
多組解:
*n1 *n5
*n2 *n4
Note:
輸出的最後必須要有一個換行符號 ("\n")
若有解,輸出數字間以一個空格隔開
若為多組解,每組解之間的輸出順序由每組解中較小的數作為排序依據
e.g.
Input:
6
5
1 2 3 4 5
Output:
(o) 1 5
2 4
(x) 2 4
1 5
若有解,每組解內的輸出順序由每組解中較小的數作為排序依據
e.g.
Input:
6
5
1 2 3 4 5
Output:
(o) 1 5
2 4
(x) 5 1
4 2
若有解,且該解在輸入陣列numberArray中有重複出現,輸出只需輸出一次
e.g.
Sample1
Input:
6
5
3 3 3 3 3
Output:
3 3
Sample2
Input:
6
11
1 1 2 2 2 3 4 4 4 5 5
Output:
1 5
2 4