C++ | O(row+col) solution
\nclass Solution {\npublic:\n    #define mod 1000000007\n    #define ll long long\n    \n    ll dp[31][31];\n    \n    void helper(int n){\n        dp[0][0] = 1
```\nclass Solution {\npublic:\n    #define mod 1000000007\n    #define ll long long\n    \n    ll dp[31][31];\n    \n    void helper(int n){\n        dp[0][0] = 1;\n        for(int i = 1; i <= n; i++){\n            for(int j = 0; j <= i; j++){\n                if(j == 0 || j == i) dp[i][j] = 1;\n                else dp[i][j] = (dp[i-1][j] + dp[i-1][j-1]) % mod;\n            }\n        }\n        return;\n    }\n    string kthSmallestPath(vector<int>& dest, int k) {\n        memset(dp, 1, sizeof(dp));\n        \n        int h = dest[1];\n        int v = dest[0];\n        \n        helper(h+v);\n        \n        int val = h+v;\n        string res = "";\n        \n        for(int i = 0; i < val; i++){\n            ll comb = dp[h+v][h];\n            ll x = h*comb/(h+v);\n            if(k <= h*comb/(h+v)){\n                res += "H";\n                h--;\n            }\n            else{\n                res += "V";\n                k -=  h*comb/(h+v);\n                v--;\n            }\n        }\n        \n        return res;\n    }\n};\n```
[]