Skip to content
Advertisement

How to get all one and two letter combinations in order from a word?

For example, there is a line

JavaScript

It is necessary to get all possible combinations, such as:

  • p-r-o-g-r-a-m
  • p-r-o-g-r-am
  • p-r-o-g-ra-m
  • pr-og-r-am

and so on.

How do I do this in java? Or at least tell me a general algorithm (with an example)?

It is not a problem to break the deadline, at least one character at a time, at least two, for example

JavaScript

But how to get (bypass) all possible combinations of one and two is not clear how to program.

Advertisement

Answer

you can do this using recursive programming:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement