LEETCODE next-permutation Solution

| August 01, 2015

The correct, optimal and working solution for programming question next-permutation on leetcode

class Solution {
public:
    void nextPermutation(vector<int> &num) {
        
        bool ans = next_permutation(num.begin(), num.end());
        if( ans == false ) {
            sort(num.begin(), num.end());
        }
    }
};