Skip to content

Commit 60eb82c

Browse files
committed
issue #41 15652
1 parent 2119d52 commit 60eb82c

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/backjoon/_15652.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,28 @@ public class _15652 {
1414
public static void main(String[] args) throws IOException {
1515
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
1616
StringTokenizer st = new StringTokenizer(br.readLine());
17-
// memory 111924 runtime 372
17+
// memory 13464 runtime 92
1818
N = Integer.parseInt(st.nextToken());
1919
M = Integer.parseInt(st.nextToken());
20+
arr = new int[M];
21+
dfs(1,0);
22+
System.out.println(sb);
23+
}
2024

25+
static void dfs(int current, int depth){
2126

27+
if(depth == M){
28+
for(int v : arr){
29+
sb.append(v).append(" ");
30+
}
31+
sb.append("\n");
32+
return;
33+
}
2234

23-
35+
for(int i=current; i<=N; i++){
36+
arr[depth] = i;
37+
dfs(i, depth+1);
38+
}
2439
}
2540
}
2641
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy