Answers for "find subsets"

0

find subsets

void subsetsUtil(vector<int>& A, vector<vector<int> >& res,
				vector<int>& subset, size_t index)
{
	res.push_back(subset);
	for (size_t i = index; i < A.size(); i++) {

		subset.push_back(A[i]);
		subsetsUtil(A, res, subset, i + 1);
		// backtracking.
		subset.pop_back();
	}

	return;
}

subsetsUtil(A, res, subset, 0);
Posted by: Guest on August-05-2021

Browse Popular Code Answers by Language