## Google Interview Question

Software Engineers**Country:**United States

//make the ans, temp vector in main. v is the given vector

void func(vector<int> &temp, vector<int> v, int i, int m, vector<vector<int> > &ans) {

if(temp.size() == m) {

ans.emplace_back(temp);

return;

}

for(int j = i; j < v.size(); j++) {

temp.push_back(v[j]);

func(temp, v, j + 1, m, ans);

temp.pop_back();

}

}

```
import random
def generate_n_list(lst, n):
if n > len(lst):
return []
if n == len(lst):
return lst
res = []
for i in range(len(lst) - 1,-1,-1):
j = random.randrange(0,i + 1,1)
temp = lst[j]
lst[j] = lst[i]
lst[i] = temp
res.append(temp)
if len(res) == n:
break
return sorted(res)
```

- LANorth July 06, 2019