剑指Offer 28题 字符串的排列 Java版
2016-10-16 00:54
399 查看
public class Permutation { public void permutation(String string){ if(string == null || string.length()==0){ return; } permutation(string.toCharArray(), 0); } public void permutation(char[] chars, int pBegin){ if(pBegin == chars.length-1){ System.out.println(chars); }else{ for(int i=pBegin; i<chars.length; ++i){ char temp = chars[i]; chars[i] = chars[pBegin]; chars[pBegin] = temp; permutation(chars, pBegin+1); temp = chars[i]; chars[i] = chars[pBegin]; chars[pBegin] = temp; } } } public static void main(String[] args) { // TODO Auto-generated method stub String string = "abc"; Permutation permutation = new Permutation(); permutation.permutation(string); } }
相关文章推荐
- 【剑指offer-Java版】28字符串的排列
- 剑指Offer面试题28(java版):字符串的排列
- [剑指offer][第四章][28]字符串的排列
- 剑指offer————面试题28(字符串排列)
- 剑指offer - 面试题28:字符串的排列(递归+去重)
- 剑指Offer----面试题28:字符串的排列 & 去重
- 剑指offer 28字符串全排列
- 剑指offer面试题28:字符串的排列
- 剑指offer——面试题28:字符串的排列(递归)
- 【剑指Offer学习】【面试题28 :字符串的排列】
- 剑指Offer-28-字符串排列
- 剑指Offer28字符串的排列(递归和非递归实现)扩展有重复元素的排列,字符串的组合种类
- 剑指offer 面试题28—字符串的排列
- 剑指offer之面试题28:字符串的排列
- 剑指offer面试题28-字符串的排列
- 剑指offer-面试题28.字符串的排列
- 剑指Offer:面试题28 字符串的排列
- 剑指offer 面试题28 字符串全排列
- 剑指offer 面试题28:字符串的排列
- 剑指offer:字符串的排列(java)