C++ || Brute force Soln (TLE) and Optimal Combinatrics Soln
Lets take given test case as example, with 2,3 eding point we know we will need 2vertical movements and 3 horizontal movements.\n\n\n/*\n   1        2       3  
Lets take given test case as example, with 2,3 eding point we know we will need 2vertical movements and 3 horizontal movements.\n\n```\n/*\n   1        2       3         4        5        6         7        8       9\n"HHHVV", "HHVHV", "HHVVH", "HVHHV", "HVHVH", "HVVHH", "VHHHV", "VHHVH", "VHVHH", \n  \n  10\n"VVHHH"\n\n(VV , HHH)\n\nH H _ _ _\n*/\n\n```\n\nIf we fix H as first position we know we will get 6 possible path and our k is less than that so we will fix H there and calculate for next step. If is k out of range we will fix V there.\n\nMoving H _ if we fix 2nd h there we will get 3 combinations and if k less equal than than then H is fixed.\n\nAnd if we fix V so we are removing all the earlier combinations from k. As V _ _ _ _ _ is at 7 index  so remove 6 from k.\n\nHope this helps even a bit.\n\n```\n//upvote if found helpful\n int comb(int n, int r){\n        \n        //nCr = n! / (n-r)! r! => n .... n-r+1/r! => n/1 * n-1/2 * n-2/3 ... n-r+1/r \n        int ans = 1;\n        \n        for(int i=1; i<=r; i++){\n            \n            ans = ans * (n-i+1)/i;\n            \n        }\n        \n        return ans;\n    }\n    \n    string kthSmallestPath(vector<int>& d, int k){\n            \n        int h = d[1], v = d[0];\n        int n = h+v;\n        string path = "";\n        \n        for(int i=0; i<n; i++){\n            \n            if(h){\n                \n                int tot_comb = comb(h+v-1, v);\n                \n                if(tot_comb >= k){\n                    path.push_back(\'H\');\n                    h--;\n                }\n                else {\n                    path.push_back(\'V\'); \n                    v--; \n                    k -= tot_comb;  \n                }\n            }\n            else{\n                path.push_back(\'V\'); \n                v--;\n            }\n        }\n        \n        return path;\n    }\n    \n};\n```\n\nBrute force : \n\n```\n    void dfs(int r, int c, int m, int n, string path, vector<string>& allPath){\n        \n        if(r<0 or r>m or c<0 or c>n) return;\n        \n        if(r==m and c==n){\n            allPath.push_back(path);\n            return;\n        }\n        \n        dfs(r+1, c, m, n, path + "V", allPath);\n        dfs(r, c+1, m, n, path + "H", allPath);\n    }\n    \n    string kthSmallestPath(vector<int>& destination, int k) {\n        vector<string> allPath;\n        int m = destination[0]; int n = destination[1];\n        dfs(0, 0, m, n, "", allPath);\n        sort(allPath.begin(), allPath.end());\n        return allPath[k-1];\n    }\n```\n
[]