Skip to content

Commit d7f4442

Browse files
committed
partition into k subsets
1 parent 4bf30a5 commit d7f4442

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

backtracking/lb-18-partition-array-into-k-subsets.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ bool helper(int a[], int n, int k, int curr_sum, int count, vector<bool>& visite
55
if (count == k - 1) return true;
66
if (curr_sum > ssm) return false;
77
// create a new subset;
8-
if (curr_sum == ssm and helper(a, n, k, 0, count + 1, visited, ssm)) return true; // as true is found no need to check further;
8+
if (curr_sum == ssm) return helper(a, n, k, 0, count + 1, visited, ssm); //
9+
// if (curr_sum == ssm and helper(a, n, k, 0, count + 1, visited, ssm)) return true; // as true is found no need to check further;
910

1011
for (int i = 0; i < n; i++) {
1112
if (!visited[i]) {

0 commit comments

Comments
 (0)