The solution set must not contain duplicate subsets.For example,
If S =[1,2,3]
, A solution is:
[ [3], [1], [2], [1,2,3], [1,3], [2,3], [1,2], []]
Show Tags
×Ó {° {£;» ~~~~~~~~~~~******************************** k ~öô ª Ø µä× Ô ° ²» ~» n'{µägate?â â ********************************************* *************************************************** comment £í û äü Ü» guí¼ Ó μ ½ solution ö{£ **************************************************** ímázomó£» mázomíçáámímímímímímímímímímímímímímémémémémémémémémémémémémémé £;è» °ó »? ~úµó ózomázä¹ ³ Ö? äamp;£.
<Strong · coding "http://www.bkjia.com/kf/ware/vc/" target = "_ blank" class = "keylink"> vcD4KPHByZSBjbGFzcz0 = "brush: java;"> class Solution {public: void sub (vector & S, int index, vector & Path, vector > & Solution) {if (s. size () = index) {solution. push_back (path); return;} sub (s, index + 1, path, solution); path. push_back (s [index]); sub (s, index + 1, path, solution); path. pop_back ();} vector > Subsets (vector & S) {vector > Solution; vector Path; sort (S. begin (), S. end (); sub (S, 0, path, solution); return solution ;}};