Skip to content

Commit 42819f1

Browse files
committed
fix: Fix spaces between comments
1 parent 4089fc9 commit 42819f1

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

dynamic_programming/0_1_knapsack.cpp

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
// 0-1 Knapsack problem - Dynamic programming
2-
//#include <bits/stdc++.h>
32
#include <iostream>
43

54
// void Print(int res[20][20], int i, int j, int capacity)
6-
//{
7-
// if(i==0 || j==0)
8-
// {
9-
// return;
10-
// }
11-
// if(res[i-1][j]==res[i][j-1])
12-
// {
13-
// if(i<=capacity)
14-
// {
15-
// cout<<i<<" ";
16-
// }
5+
// {
6+
// if(i==0 || j==0)
7+
// {
8+
// return;
9+
// }
10+
// if(res[i-1][j]==res[i][j-1])
11+
// {
12+
// if(i<=capacity)
13+
// {
14+
// std::cout<<i<<" ";
15+
// }
1716
//
18-
// Print(res, i-1, j-1, capacity-i);
19-
// }
20-
// else if(res[i-1][j]>res[i][j-1])
21-
// {
22-
// Print(res, i-1,j, capacity);
23-
// }
24-
// else if(res[i][j-1]>res[i-1][j])
25-
// {
26-
// Print(res, i,j-1, capacity);
27-
// }
28-
//}
17+
// Print(res, i-1, j-1, capacity-i);
18+
// }
19+
// else if(res[i-1][j]>res[i][j-1])
20+
// {
21+
// Print(res, i-1,j, capacity);
22+
// }
23+
// else if(res[i][j-1]>res[i-1][j])
24+
// {
25+
// Print(res, i,j-1, capacity);
26+
// }
27+
// }
2928

3029
int Knapsack(int capacity, int n, int weight[], int value[]) {
3130
int res[20][20];
@@ -35,14 +34,14 @@ int Knapsack(int capacity, int n, int weight[], int value[]) {
3534
res[i][j] = 0;
3635
} else if (weight[i - 1] <= j) {
3736
res[i][j] = max(value[i - 1] + res[i - 1][j - weight[i - 1]],
38-
res[i - 1][j]);
37+
res[i - 1][j]);
3938
} else {
4039
res[i][j] = res[i - 1][j];
4140
}
4241
}
4342
}
44-
// Print(res, n, capacity, capacity);
45-
// cout<<"\n";
43+
// Print(res, n, capacity, capacity);
44+
// std::cout<<"\n";
4645
return res[n][capacity];
4746
}
4847

0 commit comments

Comments
 (0)