-6
完美總和是兩個或更多數組元素的總和,其總和等於給定數量。如果找不到,則返回999。編寫一個計算數組中完美總和的函數?
我的方法的簽名是:
public static int persfectSum(int arr[], int input)
例如:
arr={2,3,5,6,8,10}
input = 10;
5+2+3= 10
2+8 = 10
So, the output is 2;
聽起來像作業給我,沒有任何跡象表明努力。你試過什麼了?你堅持哪一點? –
這是子集總和問題,這是NP完成 – amit
@PatriciaShanahan - 你是救世主。 –