Efficient way to find combinations of Strings in pair of two if String is an Array?

If you want to generate all possible substrings of length k from a given alphabet, then what you're doing is pretty much optimal.

If you want to generate all possible substrings of length k from a given alphabet, then what you're doing is pretty much optimal. If you want to generate all possible combinations of length k from a given set (or alphabet) with n elements (C(n, k)), then a classical solution is to use Rosen's algorithm. For example, given a 5-letter alphabet, if you want to take 3 combinations at a time, the gist of it is to count like so: 012 013 014 023 024 034 123 .. .

Here's my implementation of a RosenIterator in Java.

If you just want combinations of two strings, then your code is basically as efficient as you can get, with the following caveats: You need to be sure that the input array contains no duplicates. If the strings in the input array are not all of the same lengths, you may need to check for duplicates in the output array.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions