We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents c42d5ec + 072cc76 commit a157d91Copy full SHA for a157d91
zinnnn37/202511/15 PGM LV2 타겟 넘버.md
@@ -0,0 +1,29 @@
1
+```java
2
+public class PGM_LV2_타겟_넘버 {
3
+
4
+ private static int target, len, ans;
5
+ private static int[] nums;
6
7
+ private static void dfs(int start, int sum) {
8
+ if (start == len) {
9
+ if (sum == target) ans++;
10
+ return;
11
+ }
12
13
+ dfs(start + 1, sum - nums[start]);
14
+ dfs(start + 1, sum + nums[start]);
15
16
17
+ public int solution(int[] n, int t) {
18
+ target = t;
19
+ nums = n;
20
+ len = n.length;
21
+ ans = 0;
22
23
+ dfs(0, 0);
24
25
+ return ans;
26
27
28
+}
29
+```
0 commit comments