Search
⌘K

Leetcode 1643. Kth Smallest Instructions

Given counts of right moves (H) and down moves (V), return the k-th lexicographically smallest length-(row+column) string with those counts that reaches (row,column). The core challenge is to construct the string without enumerating all permutations by using combinatorics (n choose r) to count how many sequences start with H vs V and decide each next character accordingly.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.