public void nextPermutation(int[] num) {
		boolean found = false;
		int k = 0;
		int l = 0;

		if (num.length == 0 || num.length == 1) {
			return;
		}
		for (int i = num.length - 2; i >= 0; i--) {
			if (num[i] < num[i + 1]) {
				found = true;
				k = i;
				break;
			}
		}

		if (found == false) {// not found, the permutation is the last one,so
								// the next permutation is the reverse of it
			for (int i = 0; i < num.length / 2; i++) {
				swap(num, i, num.length - 1 - i);
			}
			return;
		}

		for (int i = num.length - 1; i > k; i--) {
			if (num[i] > num[k]) {
				l = i;
				break;
			}
		}

		swap(num, k, l);
		System.out.println(num[0]);
		reverse(num, k + 1, num.length - 1);
		return;

	}