[C++] | Simple BFS + State Management | Clean & Concise
\nclass Solution {\npublic:\n    int n;\n    queue<vector<int>> q;\n    \n    void down(vector<vector<int>>& g, vector<int>& A){\n        int r1 = A[0], c1 = A[
```\nclass Solution {\npublic:\n    int n;\n    queue<vector<int>> q;\n    \n    void down(vector<vector<int>>& g, vector<int>& A){\n        int r1 = A[0], c1 = A[1], r2 = A[2], c2 = A[3];\n        if(r1 < n - 1 && !g[r1 + 1][c1] && r2 < n - 1 && !g[r2 + 1][c2])\n            q.push({r1 + 1, c1, r2 + 1, c2});\n    }\n    void right(vector<vector<int>>& g, vector<int>& A){\n        int r1 = A[0], c1 = A[1], r2 = A[2], c2 = A[3];\n        if(c1 < n - 1 && !g[r1][c1 + 1] && c2 < n - 1 && !g[r2][c2 + 1])\n            q.push({r1, c1 + 1, r2, c2 + 1});\n    }\n    \n    void clockwise(vector<vector<int>>& g, vector<int>& A){\n        int r1 = A[0], c1 = A[1], r2 = A[2], c2 = A[3];\n        if(r1 != r2) return;\n        if(r1 < n - 1 && !g[r1 + 1][c1] && !g[r1 + 1][c2])\n            q.push({r1, c1, r1 + 1, c1});\n    }\n    void counterClockwise(vector<vector<int>>& g, vector<int>& A){\n        int r1 = A[0], c1 = A[1], r2 = A[2], c2 = A[3];\n        if(c1 != c2) return;\n        if(c1 < n - 1 && !g[r1][c1 + 1] && !g[r2][c1 + 1])\n            q.push({r1, c1, r1, c1 + 1});\n    }\n    set<vector<int>> set;\n    \n    int minimumMoves(vector<vector<int>>& g) {\n        n = g.size();\n        q.push({0, 0, 0, 1});\n        int level = 0;\n        while(!q.empty()){\n            int sz = q.size();\n            for(int i = 0; i < sz; i++){\n                auto A = q.front();\n                q.pop();\n                if(set.find(A) != set.end()) continue;\n                set.insert(A);\n                int r1 = A[0], c1 = A[1], r2 = A[2], c2 = A[3];\n                if(r1 == n - 1 && c1 == n - 2 && r2 == n - 1 && c2 == n - 1)    return level;\n                down(g, A); right(g, A);\n                clockwise(g, A); counterClockwise(g, A);\n            }\n            level++;\n        }\n        return -1;\n    }\n};\n```
['Breadth-First Search', 'C', 'C++']