It seems the test cases of leetcode does not consider the inputs that have same numbers in the collection?
For example, [1,3,3].
[leetcodeonly] [testcase] Don't we need to consider the inputs that have same numbers in the collection?

That Permutations 2!
Maybe in Permutations, "collection" should be replaced by "set".

Here is my solution which takes care of duplicate numbers too..
class Solution { public: vector<vector<int>> ans; void func(vector<int> &num,vector<int> a,int visited[], int pos) { if(pos==num.size()) { ans.push_back(a); return; } for(int i=0;i<num.size();i++) { if(visited[i]==false) { if(a.size()<=pos) a.push_back(num[i]); else a[pos]=num[i]; visited[i]=true; func(num,a,visited,pos+1); visited[i]=false; } } } vector<vector<int> > permute(vector<int> &num) { vector<int> a; int visited[1000]; for(int i=0;i<num.size();i++) visited[i]=false; func(num,a,visited,0); return ans; } };