Lattice word

In mathematics, a lattice word (or lattice permutation) is a string composed of positive integers, in which every prefix contains at least as many positive integers i as integers i + 1.

A reverse lattice word, or Yamanouchi word, is a string whose reversal is a lattice word.

Examples
For instance, 11122121 is a lattice permutation, so 12122111 is a Yamanouchi word, but 12122111 is not a lattice permutation, since the prefix 12122 contains more 2s than 1s.