Test code has a bug


  • 0
    W

    The test accepts this code where I don't return anything. I don't understand what the test code is checking...

    class Solution 
    {
    public:
        vector<vector<int>> permute(vector<int>& nums) 
        {
            vector<vector<int>> result;
            if (nums.empty()) return result;
        
            sort(nums.begin(), nums.end());
            do
            {
                result.push_back(nums);
            } while (next_permutation(nums.begin(), nums.end()));
        }
    };

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.