c++ | 100% faster than all | easy
\n# Code\n\nclass Solution {\n int comb(int n, int r) {\n        long ans = 1;\n        for (int i = 1, j = n - r + 1; i <= r; ++i, ++j) ans = ans * j / i;\n   
\n# Code\n```\nclass Solution {\n int comb(int n, int r) {\n        long ans = 1;\n        for (int i = 1, j = n - r + 1; i <= r; ++i, ++j) ans = ans * j / i;\n        return ans;\n    }\npublic:\n    string kthSmallestPath(vector<int>& A, int k) {\n        int h = A[1], v = A[0], N = h + v;\n        string s;\n        for (int i = 0; i < N; ++i) {\n            if (h) { \n                int c = comb(h - 1 + v, v); \n                if (k <= c) { \n                    s += \'H\';\n                    --h;\n                } else { \n                    k -= c;\n                    s += \'V\';\n                    --v;\n                }\n            } else { \n                s += \'V\';\n                --v;\n            }\n        }\n        return s;\n    }\n};\n```
['C++']