国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

Permutations II

2019-11-14 13:01:29
字體:
供稿:網(wǎng)友

Given a collection of numbers that might contain duplicates, return all possible unique permutations.

For example,[1,1,2] have the following unique permutations:[1,1,2][1,2,1], and [2,1,1].

void visit(vector<int> &num, int n, int pos){	if (n == pos)	{		for (int i = 0; i < num.size(); i++)		{			cout << num[i] << " ";		}		cout << endl;		return;	}	for (int i = pos; i < n; i++)	{		if (num[i] == num[pos] && i != pos)		{			continue;		}		swap(num[i], num[pos]);		visit(num, n, pos+1);		swap(num[i], num[pos]);	}}void fun(vector<int> &num){	int n = num.size();	sort(num.begin(), num.end());	visit(num, n, 0);}


發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 遵化市| 竹山县| 玛多县| 天门市| 南溪县| 荔浦县| 彭泽县| 海兴县| 沅陵县| 萨嘎县| 普陀区| 宜春市| 雷州市| 达孜县| 中卫市| 门头沟区| 汶上县| 岚皋县| 闻喜县| 海城市| 临西县| 三台县| 大冶市| 云和县| 金溪县| 前郭尔| 武宁县| 白银市| 安义县| 南木林县| 平和县| 云阳县| 孟村| 菏泽市| 和平县| 湖口县| 亚东县| 上杭县| 砚山县| 黄石市| 礼泉县|