Very easy c++
\nclass Solution {\npublic:\n    vector minReverseOperations(int n, int p, vector& banned, int k) {\n        vector out(n, -1);\n\n        for (int node : banne
\nclass Solution {\npublic:\n    vector<int> minReverseOperations(int n, int p, vector<int>& banned, int k) {\n        vector<int> out(n, -1);\n\n        for (int node : banned) {\n            out[node] = -2;\n        }\n\n        vector<int> nodes{p};\n        int depth = 0;\n        out[p] = depth;\n        int step = k - 1;\n        \n\n        vector<int> nextNode2s(n, 0);\n        for (int i = 0; i < n; ++i) {\n            nextNode2s[i] = i + 2; \n        }\n\n        while (!nodes.empty()) {\n            depth += 1;\n            vector<int> newNodes;\n            for (int node1 : nodes) {\n              \n                int loReverseStart = max(node1 - step, 0);\n                int hiReverseStart = min(node1, n - k); \n                int loNode2 = 2 * loReverseStart + k - 1 - node1;\n                int hiNode2 = 2 * hiReverseStart + k - 1 - node1;  \n             \n                int postHiNode2 = hiNode2 + 2;\n                int node2 = loNode2;\n                while (node2 <= hiNode2) {\n                    int nextNode2 = nextNode2s[node2];\n                    nextNode2s[node2] = postHiNode2;\n                    if (node2 >= 0 && node2 < n && out[node2] == -1) {\n                        newNodes.push_back(node2);\n                        out[node2] = depth;\n                    }\n                    node2 = nextNode2;\n                }\n            }\n            nodes = newNodes;\n        }\n        \n       \n        for (int i = 0; i < n; ++i) {\n            if (out[i] == -2) {\n                out[i] = -1;\n            }\n        }\n        return out;\n    }\n};\n\n
['C++']