Added solution for Lexicographic permutations