博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
剑指Offer-27-字符串的排列-分路法
阅读量:3725 次
发布时间:2019-05-22

本文共 678 字,大约阅读时间需要 2 分钟。

题目描述

输入一个字符串,按字典序打印出该字符串中字符的所有排列。例如输入字符串abc,则打印出由字符a,b,c所能排列出来的所有字符串abc,acb,bac,bca,cab和cba。

import java.util.ArrayList;import java.util.Collections;public class Solution {    public ArrayList
Permutation(String str) { ArrayList
array = new ArrayList
(); if(str==null||str.length()<=0){ return array; } charPermutation(array,str.toCharArray(),0); Collections.sort(array); return array; } public void charPermutation(ArrayList
array,char[] cc,int index){ if(index==cc.length-1){ array.add(new String(cc)); return ; } for(int i=index;i

 

转载地址:http://cyonn.baihongyu.com/

你可能感兴趣的文章
你们会选择哪种深度学习开源框架?Pytorch还是Caffe、TensorFlow?各家的优缺点都有哪些?
查看>>
C++和C的不同之处(不断自更新)自学笔记
查看>>
指针小结(摘自C++程序设计教程)
查看>>
HTML基础
查看>>
几个概念
查看>>
数据库简介
查看>>
MySQL操作
查看>>
关于表的操作
查看>>
数据操作
查看>>
MySQL数据类型
查看>>
git 关于 git push origin master 失败的问题解决
查看>>
古风排版
查看>>
编译和交叉编译openssl
查看>>
ubuntu下载安装Eclipse for c/c++ developers
查看>>
Sourcetree跳过注册和git和mercurial安装
查看>>
c语言16进制字符串转字节数组
查看>>
ubuntu下安装CUnit出现的问题及解决
查看>>
c语言获取本地时间
查看>>
ubuntu中openwrt编译环境的搭建
查看>>
从字符串中获取指定字符串之间字符串
查看>>