bfs +hashset
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\npublic class Solution {\n    public int MinimumMoves(int[][] g) {\n       Queue<int[]> p= new Queue<int[]>();\n       int n=g.Length;\n      \n       p.Enqueue(new int[]{0,0,0,1,1});\n       int ans=0;\n       HashSet<string> s= new HashSet<string>();\n       while (p.Count>0){\n           int l=p.Count;\n           for (int i=0; i<l; i++){\n             int []a= p.Dequeue();\n             string key= a[0]+"-"+a[1]+"+"+a[2]+"-"+a[3];\n             if (s.Contains(key))continue;\n             else s.Add(key);\n             \n     if (a[0]==n-1 && a[1]==n-2 && a[2]==n-1 && a[3]==n-1 ) {Console.WriteLine("pera"); return ans;}\n            if(a[4]==1 ){\n                if (a[3]+1<n && g[a[2]][a[3]+1]==0){\n                    p.Enqueue(new int []{a[0],a[1]+1,a[2],a[3]+1,1});\n                }\n                 if (a[2]+1<n && g[a[2]+1][a[3]]==0 &&g[a[0]+1][a[1]]==0){\n                    p.Enqueue(new int []{a[0]+1,a[1],a[2]+1,a[3],1});\n                }\n\n                if (a[0]+1<n && g[a[0]+1][a[1]]==0&& g[a[0]+1][a[1]+1]==0){\n                    p.Enqueue(new int []{a[0],a[1],a[0]+1,a[1],0});\n                }\n            }\n            else {\n                 if (a[2]+1<n && g[a[2]+1][a[3]]==0){\n                    p.Enqueue(new int []{a[0]+1,a[1],a[2]+1,a[1],0});\n                }\n                 if (a[3]+1<n && g[a[2]][a[3]+1]==0 && g[a[0]][a[1]+1]==0){\n                    p.Enqueue(new int []{a[0],a[1]+1,a[2],a[3]+1,0});\n                }\n                if (a[1]+1<n && g[a[0]][a[1]+1]==0 && g[a[2]][a[1]+1]==0){\n                    p.Enqueue(new int []{a[0],a[1],a[0],a[1]+1,1});\n                }\n            }\n           }\n          ans++;\n       }\nreturn -1;\n    }\n}\n```
['C#']