Friday, October 11, 2013

Permutation Problem [Summary]

  1. Print all permutations of a given string in sorted (lexicographic) order [GeeksforGeeks]
  2. Print all permutations of a given string [GeeksforGeeks]
  3. Print all permutations with repetition of characters of a given string [GeeksforGeeks]
  4. Print all permutations of a collection of numbers [Leetcode]
  5. Print all unique permutations of a given collection of numbers that might contain duplicates [Leetcode] [Analysis]
  6. Next Permutation [Leetcode]
  7. K-th Permutation[Leetcode]
#1 is based on #6. [If the given string has repeated chars, the duplicate permutations may be generated. we can avoid it by keeping track of the previous permutation. While printing, if the current one is the same as the previous one, we ignore it; the time complexity O(n*n!)]
#2 and #4 are the same problem, they can be solved by either dynamic programming or backtracking.
#5 is based on #2 and #4, the extra work is to eliminate duplicates.
#7 needs to find out the mathematical pattern [my solution].

No comments:

Post a Comment