Java - math solution
```\nclass Solution {\n    public String kthSmallestPath(int[] destination, int k) {\n        int hs = destination[1];\n        int vs = destination[0];\n      
```\nclass Solution {\n    public String kthSmallestPath(int[] destination, int k) {\n        int hs = destination[1];\n        int vs = destination[0];\n        // the destination decided how many H and how many V should in the return string\n        return find(hs, vs, k);\n        \n    }\n    \n    private String find(int h, int v, int k) {\n        if (h == 0) {\n            char[] chars = new char[v];\n            Arrays.fill(chars, \'V\');\n            return new String(chars);\n        } else if (v == 0) {\n            char[] chars = new char[h];\n            Arrays.fill(chars, \'H\');\n            return new String(chars);\n        }\n        // if return has no H or V, then we can directly return it. Should have better way to generate strings.   \n        int total = h + v;\n        int chance = ncr(total - 1, v);\n\t\t// If we have 3 H and 2 V, totally we have ncr(5,2)=10 combinations, if first one is H, then all the combination has ncr(4, 2) = 6. So if K is bigger than it, means first one should be V. otherwise first letter is H.\n\t\t\n        if (k <= chance) {\n            return "H" + find(h - 1, v, k);\n\t\t\t// if we ignore the first letter, then we have 2 H and 2 V left, run the function again to find it.\n        } else {\n            return "V" + find(h, v - 1, k - chance);\n\t\t\t// if first one is V, then we need remove the ncr(4, 2) combinations of k. Since we need find the other 4 letters order.\n        }\n    }\n    \n\t//This funciton is used to find the ncr which mentioned in the question.\n    private int ncr(int a, int b){\n        int count = 1;\n        int prod = 1;\n        while (count <= b) {\n            prod = prod * a / count;\n            a--;\n            count++;\n        }\n        return prod;\n    }\n}\n\'\'\'\n
[]