1 class Solution { 2 public: 3 void getP(vector> &result, vector &num, vector current, vector rec) { 4 if (num.size() == current.size()) { 5 result.push_back(current); 6 return; 7 } 8 for (int i = 0; i < num.size(); i++) { 9 if (rec[i] || (i > 0 && num[i] == num[i-1] && rec[i-1])) continue;10 rec[i] = true;11 current.push_back(num[i]);12 getP(result, num, current, rec);13 rec[i] = false;14 current.pop_back();15 }16 }17 vector > permuteUnique(vector &num) {18 vector > result;19 sort(num.begin(), num.end());20 getP(result, num, vector (), vector (num.size(), false));21 return result;22 }23 };