AccioJob Interview Question

Next higher permutation. Longets common subsequence