NEXT-PERMUTATION leetcode Solution - Correct, Optimal and Working

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

470+ Solutions to various Programming Questions

Subscribe to my weekley newsletter