摘要:
求一个排列的下一个排列。1,2,3→1,3,23,2,1→1,2,31,1,5→1,5,1#include #include #include using namespace std; class Solution{public: void nextPermutation(vector &nu...
阅读全文
posted @ 2014-06-12 20:08
qingcheng奕
阅读(175)
推荐(0)
摘要:
给的一个数列中,可能存在重复的数,比如 1 1 2 ,求其全排列。记录上一个得出来的排列,看这个排列和上一个是否相同。#include #include #include using namespace std; class Solution{public: vector > permuteU...
阅读全文
posted @ 2014-06-12 19:50
qingcheng奕
阅读(178)
推荐(0)
摘要:
https://oj.leetcode.com/problems/permutations/写出一列数的全排列#include #include #include using namespace std; class Solution{public: vector > permute(vect...
阅读全文
posted @ 2014-06-12 19:43
qingcheng奕
阅读(164)
推荐(0)
摘要:
2 8 5 3 11.从后往前,找到第一个逆序的数 pivot2.从后往前,找到第一个比pivot大的数 change3.交换 pivot 和 change的值4.把pivot这个位置后面的数 reverse,就是 8 5 2 1变成 1 2 5 8最终为3 1 2 5 8#include #inc...
阅读全文
posted @ 2014-06-12 19:21
qingcheng奕
阅读(264)
推荐(0)