×

# SHELPASS - Editorial

 0 Sheldon Password Problem practice Tags: Permutation. Author: Shami. This problem is a fancy way of asking to compute Kth permutation given a starting string. Since the maximum length of string is only 9, we can map the letters to digits and work with numbers (if that is more comfortable). How to find the next permutation? This Wiki article describes the following steps: Find the largest index k such that a[k] < a[k + 1]. If no such index exists, the permutation is the last permutation. Find the largest index l greater than k such that a[k] < a[l]. Swap the value of a[k] with that of a[l]. Reverse the sequence from a[k + 1] up to and including the final element a[n]. However, if you are programming in C++, you’ll be happy to know there is a function that just does that! asked 12 Jan, 14:18 0★mmmreddy 12●1 accept rate: 0%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×168