Java, O(r*c) very easy to understand
time complexity O(row * col)\nit\'s a variation of the dungeon games, we can solve it in a similar way\n\npublic String kthSmallestPath(int[] destination, int k
time complexity O(row * col)\nit\'s a variation of the dungeon games, we can solve it in a similar way\n```\npublic String kthSmallestPath(int[] destination, int k) {\n        \n        int ti = destination[0], tj = destination[1];\n        int[][] dp = new int[ti+1][tj+1];\n        for(int i = ti; i >= 0; i--){\n            for(int j = tj; j >= 0; j--){\n                if(i == ti && j == tj){\n                    dp[i][j] = 1;\n                }else if(i == ti){\n                    dp[i][j] = dp[i][j+1];\n                }else if(j == tj){\n                    dp[i][j] = dp[i+1][j];\n                }else{\n                    dp[i][j] = dp[i+1][j] + dp[i][j+1];\n                }\n            }\n        }\n        \n        \n        // in each (i, j), we have dp[i][j] kind of instructions, which equal to dp[i][j+1] + dp[i+1][j]\n        // all dp[i][j+1] kinds of instructions are lexicographically smaller than the left dp[i+1][j] kinds of instructions.\n        // we can just compare k with dp[i][j+1] to determin how to choose next step.\n        \n        StringBuilder sb = new StringBuilder();\n        helper(dp, 0, 0, k, sb);\n        return sb.toString();\n    }\n    \n    private void helper(int[][] dp, int i, int j, int k, StringBuilder sb){\n        \n        if(i == dp.length -1){\n            // if we came to most down position then we can only go right\n            while(++j < dp[0].length)sb.append("H");\n            return;\n        }\n        if(j == dp[0].length - 1){\n            //if we came to most right position then we can only go down\n            while(++i < dp.length)sb.append("V");\n            return;\n        }\n        if(dp[i][j+1] >= k){\n            //if k is smaller than the first dp[i][j+1] solutions, then we should go right\n            sb.append("H");\n            helper(dp, i, j+1, k, sb);\n        }else{\n            //else we go donw, and we should also minus the first dp[i][j+1] solutions from k\n            sb.append("V");\n            helper(dp, i+1, j, k-dp[i][j+1], sb);\n        }\n    }\n```
[]