剑指offer 28. 字符串的全排列
2017-05-05 16:55
267 查看
//题目:输入一个字符串,输出字符串的全排列 //解法:确定字符串的第一个字符,然后递归求之后字符的全排列 public class Main { public static void main(String[] args) throws Exception { printAllSeq("abc"); } public static void printAllSeq(String str){ if(str == null){ return; } char[] input = str.toCharArray(); printAllSeqHelper(input,0); } public static void printAllSeqHelper(char[] input, int begin){ if(begin == input.length-1){ System.out.println(input); }else{ for(int i = begin;i<input.length;i++){ char temp = input[begin]; input[begin] = input[i]; input[i] = temp; printAllSeqHelper(input,begin+1); temp = input[begin]; input[begin] = input[i]; input[i] = temp; } } } }
相关文章推荐
- 剑指Offer面试题28字符串的排列组合(递归和栈)
- 剑指Offer——面试题28:字符串的排列
- 【剑指offer】面试题28:字符串的排列
- 剑指Offer28字符串的排列(递归和非递归实现)扩展有重复元素的排列,字符串的组合种类
- 剑指offer 28 字符串的排列
- 剑指offer-面试题28:字符串的排列
- 剑指offer-面试题28 字符串的排列
- 剑指Offer 28题 字符串的排列 Java版
- 剑指Offer:面试题28 字符串的排列
- 剑指Offer面试题28(java版):字符串的排列
- 剑指offer-面试题28-字符串的排列
- 剑指offer28:字符串的排列
- 剑指offer 28题 【分解让复杂问题简单】字符串的排列
- 剑指offer - 面试题28:字符串的排列(递归+去重)
- 剑指Offer_面试题28_字符串的排列
- 剑指offer-面试题28.字符串的排列
- 剑指offer面试题28: 字符串的排列
- [剑指offer][第四章][28]字符串的排列
- 剑指Offer----面试题28:字符串的排列 & 去重
- 剑指offer 面试题28:字符串的排列