This problem asks us to list all possible combinations, so we can use backtracking to find them. However, we must avoid finding duplicated combinations.
We must first understand what the competitive subsequence in the problem is. When a is more competitive than b, this means that the letters of a are smaller than the letters of b at the same position.
This problem requires us to point the next of the left node in each layer to the right node. Because it is processed layer by layer, it is very intuitive to think of using BFS to solve it.
This problem requires us to point the next of the left node in each layer to the right node. Because it is processed layer by layer, it is very intuitive to think of using BFS to solve it.