backtrack
that takes the current path (string being built) and the position to insert the next character.n
, decrement k
and check if k
is zero. If so, store the current path as the answer.k
is not zero, iterate over the characters 'a', 'b', and 'c'.backtrack
with the updated path and position.k
reaches zero, backtrack by removing the last character from the path.k
is zero; otherwise, return an empty string.