AccioJob interview question

Next higher permutation. Longets common subsequence