My Solution
\n/**\n * Time Complexity: O((total_v + total_h) * total_v)\n * Space Complexity: O((total_v + total_h) * total_v)\n * where `total_v` is `destination.front()`\
```\n/**\n * Time Complexity: O((total_v + total_h) * total_v)\n * Space Complexity: O((total_v + total_h) * total_v)\n * where `total_v` is `destination.front()`\n *       `total_h` is `destination.back()`\n */\nclass Solution {\n public:\n  string kthSmallestPath(const vector<int> &destination, const int k) {\n    constexpr char h = \'H\';\n    constexpr char v = \'V\';\n    const int total_v = destination.front();\n    const int total_h = destination.back();\n    int ncr[total_h + total_v + 1][total_v + 1];\n    memset(ncr, 0, sizeof(ncr));\n    for (int i = 0; i < total_h + total_v + 1; ++i) {\n      for (int j = 0; j < total_v + 1; ++j) {\n        if (j == 0) {\n          ncr[i][j] = 1;\n          continue;\n        }\n        if (i == 0) {\n          continue;\n        }\n        ncr[i][j] = ncr[i - 1][j] + ncr[i - 1][j - 1];\n      }\n    }\n    string ret;\n    for (int remains_v = total_v, remains_h = total_h, remains = k; true; ) {\n      if (remains == 1) {\n        ret.append(remains_h, h).append(remains_v, v);\n        break;\n      }\n      \n      const int consumed = ncr[remains_v + remains_h - 1][remains_v];\n      if (consumed < remains) {\n        ret.push_back(v);\n        remains -= consumed;\n        --remains_v;\n      } else {\n        ret.push_back(h);\n        --remains_h;\n      }\n    }\n    return ret;\n  }\n};\n```
[]