摘要: Given a collection of numbers, return all possible permutations.For example,[1,2,3]have the following permutations:[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2], and[3,2,1]. 1 class Solution { 2 public: 3 vector > permute(vector &num) { 4 vector > result; 5 sort(num.begin(), num.end())... 阅读全文
posted @ 2014-03-18 16:35 小菜刷题史 阅读(168) 评论(0) 推荐(0) 编辑
摘要: The set[1,2,3,…,n]contains a total ofn! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, forn= 3):"123""132""213""231""312""321"Givennandk, return thekthpermutation sequence.Not 阅读全文
posted @ 2014-03-18 16:06 小菜刷题史 阅读(149) 评论(0) 推荐(0) 编辑
摘要: Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).The replacement must be in-place, do not allocate extra memory.He 阅读全文
posted @ 2014-03-18 13:09 小菜刷题史 阅读(274) 评论(0) 推荐(0) 编辑