C++ | DP | Memoization | Recursion
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```\nclass Solution {\npublic:\n    double f(int n , int k , int nr , int nc , vector<vector<vector<double>>>& dp)\n    {\n        if(nc<0 || nr<0 || nc>=n || nr>=n) return 0;\n        if(k==0) return 1;\n        if(dp[nr][nc][k]!=-1) return dp[nr][nc][k];\n        int r[]={-2,-2,-1,1,2,2,1,-1};\n        int c[]={-1,1,2,2,1,-1,-2,-2};\n        double prob = 0;\n        for(int i=0;i<8;i++)\n        {\n            prob += f(n,k-1,nr+r[i] , nc+c[i],dp)/8.0;\n        }\n        return dp[nr][nc][k]=prob;\n    }\n\n    double knightProbability(int n, int k, int row, int col) {\n        if(k==0) return 1;\n        vector<vector<vector<double>>> dp(n , vector<vector<double>>(n,vector<double>(k+1,-1)));\n         return f(n , k , row , col , dp);\n    }\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n```
['Dynamic Programming', 'Recursion', 'Memoization', 'C++']