941.cpp, C++ Solution of string-processing problem: UVa 941 - Permutations. In this post we will see how we can solve this challenge in C++ for UVa Online Judge.

Problem Description

A permutation of a string is the set of all possible ways to combine its characters. E.g., the permutation of “abc” is {“abc”, “acb”, “bac”, “bca”, “cab”, “cba”}. The size of this set is the factorial of the initial string size.

Given a string S (with up to 20 characters, all lowercase letters) and a integer N (0 ≤ N < 20!) find the (N + 1)-th smallest element of the permutation of S (consider t


You can find the full details of the problem Permutations at UVa Online Judge

Solution: Please check the 941.cpp snippet for the solution.

Solution originally posted at: Github by @SITZ