Simple & fast recursive Ruby solution (10ms)
ApproachI named the row and column ofdestination vandhbecause they are the number of 'V' and 'H' required in the path.Since we want to consider the paths in lex
# Approach

*I named the row and column of `destination` `v` and `h` because they are the number of 'V' and 'H' required in the path.*

Since we want to consider the paths in lexi order, we know all paths starting with 'H' come first.

After the 'H', we have the same problem with one fewer column. So if there are `nCr(v+h, h)` paths, there must be `nCr(v+h-1, h-1)` paths starting with 'H'.

If our `k` is less than that, we can just find the $$\textrm{k}^{th}$$ of those shorter strings and put 'H' before it. If our `k` is larger, we put 'V' first and subtract that many from `k` while recursing.

Then we just need base cases. When either `v` or `h` gets to zero, we know the string must consist only of the other direction, so we can return that.

# Code
```ruby []
# Calculates nCr(v+h, h)
def max_k(v, h) 
    v, h = h, v if v < h # slight efficiency boost
    (v+1).upto(v+h).reduce(1, :*) / 2.upto(h).reduce(1, :*)
end

def kth_smallest_path(destination, k)
    v, h = destination
    return "V" * v if h.zero?
    return "H" * h if v.zero?

    h_paths = max_k(v, h - 1)

    if k <= h_paths
        'H' + kth_smallest_path([v, h - 1], k)
    else
        'V' + kth_smallest_path([v - 1, h], k - h_paths)
    end
end
```
['Ruby']