What is an elegant way to find all the permutations of a string. Generating all permutations of a given string. Find all possible combinations of String in java : code with example All combination of string in java is the. Write a c program to find all the permutations of a given string. Example: If the given string is sam. C program to replace the sub string with another. Combinations of a String » My Tech Interviews. Question: Write an algorithm to print all possible combinations of characters in a string. Answer: Any thoughts? One thing is for sure, we can definitely use some recursive logic here. Let’s approach this problem methodically. Since we need to generate combinations, we can start with a single character and then continue to add a character to combinations we have seen so far. Let’s use “abc” as an example. Here’s some code in Java (for a change : )) to achieve what we’ve described above. String instr, String. Buffer outstr, int index). Please let us know through the comments section. Continue Reading Below.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2016
Categories |