# 全排列

<p>给定一个<strong> 没有重复</strong> 数字的序列，返回其所有可能的全排列。</p><p><strong>示例:</strong></p><pre><strong>输入:</strong> [1,2,3]<strong><br />输出:</strong>[  [1,2,3],  [1,3,2],  [2,1,3],  [2,3,1],  [3,1,2],  [3,2,1]]</pre>

## template

```java
class Solution {
	public List<List<Integer>> permute(int[] nums) {

		List<List<Integer>> result = new ArrayList<List<Integer>>();
		Arrays.sort(nums);
		List<Integer> first = new ArrayList<Integer>();
		for (int r = 0; r < nums.length; r++) {
			first.add(nums[r]);
		}
		result.add(first);
		int i = nums.length - 2;
		while (i >= 0) {
			if (nums[i] < nums[i + 1]) {
				int temp = nums[i];
				for (int j = nums.length - 1; j > i; j--) {
					if (nums[j] > temp) {
						nums[i] = nums[j];
						nums[j] = temp;
						break;
					}
				}
				nums = quick_sort(nums, i + 1, nums.length - 1);
				List<Integer> sub = new ArrayList<Integer>();
				for (int t = 0; t < nums.length; t++) {
					sub.add(nums[t]);
				}
				result.add(sub);
				i = nums.length - 2;

			} else {
				i--;
			}
		}

		return result;

	}

	public int[] quick_sort(int[] a, int left, int right) {
		if (left < right) {
			int l = left;
			int r = right;
			int temp = a[l];
			while (l != r) {
				while (l < r && a[r] > temp) {
					r--;
				}
				if (l < r) {
					a[l] = a[r];
					l++;
				}

				while (l < r && a[l] < temp) {
					l++;
				}
				if (l < r) {
					a[r] = a[l];
					r--;
				}

			}
			a[l] = temp;
			quick_sort(a, left, l - 1);
			quick_sort(a, l + 1, right);
		}
		return a;
	}
}
```

## 答案

```java

```

## 选项

### A

```java

```

### B

```java

```

### C

```java

```