C++ dynamic programming
The idea is to a matrix "dp". where dp[i][j] stores the number of ways from (i,j) to (m, n).\nAt (i, j), we need to determine the next move: whether to (i+1, j)
The idea is to a matrix "dp". where dp[i][j] stores the number of ways from (i,j) to (m, n).\nAt (i, j), we need to determine the next move: whether to (i+1, j) or (i, j+1).\n\n```\nclass Solution {\npublic:\n    string kthSmallestPath(vector<int>& destination, int k) {\n        int m = destination[0], n = destination[1];\n        \n        vector<vector<int>> dp(m+2, vector<int>(n+2, 0));\n        dp[m][n] = 1;\n        for(int i=m; i>=0; i--) {\n            for(int j=n; j>=0; j--) {\n                if(i == m && j == n) continue;\n                dp[i][j] = dp[i+1][j] + dp[i][j+1];\n            }\n        }\n        \n        string ans = "";\n        int r = 0, c = 0;\n        int step = 0, remain = k;\n        for(int step = 0; step < m+n; step++) {\n            if(dp[r][c+1] >= remain) {\n                c = c+1;\n                ans += \'H\';\n            } else {\n                remain -= dp[r][c+1];\n                r = r+1;\n                ans += \'V\';\n            }\n        }\n        \n        return ans;\n    }\n};\n```
[]