Imagine Bob is on a treasure hunt on a grid! Bob starts at the top-left corner (0, 0) and wants to reach his treasure at position (row, column). However, Bob can only move in two directions:
- 'H' - Move horizontally (right)
- 'V' - Move vertically (down)
For example, to reach (2, 3), Bob needs exactly 3 H's and 2 V's. Valid instruction sequences include "HHHVV", "HVHVH", "VHHVH", and many more!
Here's the twist: Bob has a lucky number k, and he wants the k-th lexicographically smallest instruction sequence. Since 'H' comes before 'V' alphabetically, "HHHVV" would come before "HVHVH".
Goal: Given the destination coordinates and Bob's lucky number k, return the k-th lexicographically smallest instruction sequence that will get Bob to his treasure!
Input & Output
Constraints
- 1 โค destination[0], destination[1] โค 15
- 1 โค k โค C(destination[0] + destination[1], destination[0])
- k is guaranteed to be valid (within the range of possible sequences)