严氏北美IT公司面试真题汇总和解答论坛
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Combination SumIV 不难最好bug free 面试官可能让你还要用DP实现 dp在其它post中

Go down

Combination SumIV 不难最好bug free 面试官可能让你还要用DP实现 dp在其它post中 Empty Combination SumIV 不难最好bug free 面试官可能让你还要用DP实现 dp在其它post中

Post by Admin Sat Oct 21, 2017 4:57 pm

public static int DFS(int[] nums, int target) {
if (target == 0) {
return 1;
}
int res = 0;
for (int i = 0; i < nums.length; i++) {
if (target >= nums[i]) {
res += DFS(nums, target - nums[i]);
}
}
return res;
}

Admin
Admin

Posts : 124
Join date : 2017-10-21

https://csinterviewquestions.forumotion.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum