Git Product home page Git Product logo

Comments (3)

FlandiaYingman avatar FlandiaYingman commented on September 15, 2024 1

好像对了,这样:

vector<vector<int>> enumerate_all_permutations(int* arr, int arr_len, int count) {
    vector<vector<int>> result;
    if (count == 1) {
        for (int i = 0; i < arr_len; i++) {
            vector<int> v;
            v.push_back(arr[i]);
            result.push_back(v);
        }
        return result;
    }
    for (int i = 0; i < arr_len - (count-1); i++) {
        int key = arr[i];
        vector<vector<int>> v = enumerate_all_permutations(arr+i+1, arr_len-i-1, count-1);
        for (int j = 0; j < v.size(); j++) {
            v[j].push_back(key);
            result.push_back(v[j]);
        }
    }
    return result;
}

from 15-year-old-konjac-wants-to-learn-oi.

FlandiaYingman avatar FlandiaYingman commented on September 15, 2024

我操啊,到底怎么链接 commit 啊……

from 15-year-old-konjac-wants-to-learn-oi.

FlandiaYingman avatar FlandiaYingman commented on September 15, 2024

Resolved: fc43181 in resolved/algorithms_implementation/Enumerate_All_Permutations.cpp
(就这样吧)

from 15-year-old-konjac-wants-to-learn-oi.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.