Compile Error in this platform!


  • -1
    C

    I have tried the same code in VS2015,it can run successfully on it.However,when I try to submit this code,the platform always warn that compile error with empty tips.I am really confused where the mistake is.
    class Solution {
    public:
    vector<vector<int>> permute(vector<int>& nums) {
    vector<vector<int>> backtracking(const int length,vector<int>& nums, vector<vector<int>> &results, int index, vector<int> &result);
    vector<vector<int>> results;
    vector<int> result;
    results = backtracking(nums.size(),nums, results, 0, result);
    return results;
    }

    vector<vector<int>> backtracking(const int length,vector<int>& nums, vector<vector<int>> &results, int index, vector<int> &result) {
        if (index == length) {
            results.push_back(result);
        }
        else {
            for (int i = 0;i<nums.size();i++) {
                result.push_back(nums[i]);
                int tmp = nums[i];
                nums.erase(nums.begin()+i);
                backtracking(length,nums, results, index + 1, result);
                nums.insert(nums.begin()+i,tmp);
                result.pop_back();
            }
        }
        return results;
    }
    

    };


Log in to reply
 

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