Kth Smallest Instructions
Code\npython []\ndef comb(n, r):\n    if r > n:\n        return 0\n    if r == 0 or r == n:\n        return 1\n    r = min(r, n - r)  # Take advantage of symmet
# Code\n```python []\ndef comb(n, r):\n    if r > n:\n        return 0\n    if r == 0 or r == n:\n        return 1\n    r = min(r, n - r)  # Take advantage of symmetry\n    numerator = 1\n    denominator = 1\n    for i in range(r):\n        numerator *= (n - i)\n        denominator *= (i + 1)\n    return numerator // denominator\n\nclass Solution(object):\n    def kthSmallestPath(self, destination, k):\n        """\n        :type destination: List[int]\n        :type k: int\n        :rtype: str\n        """\n        row, column = destination\n        result = []\n        \n        while row > 0 and column > 0:\n            # Calculate how many paths start with \'H\' (choose column-1 \'H\'s and row \'V\'s)\n            paths_with_H_first = comb(row + column - 1, row)\n            \n            if k <= paths_with_H_first:\n                # The k-th path starts with \'H\'\n                result.append(\'H\')\n                column -= 1\n            else:\n                # The k-th path starts with \'V\'\n                result.append(\'V\')\n                k -= paths_with_H_first\n                row -= 1\n        \n        # If there are no \'H\'s left, append all remaining \'V\'s\n        result.extend([\'H\'] * column)\n        result.extend([\'V\'] * row)\n        \n        return \'\'.join(result)\n        \n```
['Python']