All Questions
8 questions
8
votes
2
answers
557
views
Method to generate a List<string> containing permutation of an input string
I'm working to understand Big O notation. As such I'm going through examples and the algorithm below generates the permutations for a given input string which contains only distinct characters. IE no ...
6
votes
1
answer
656
views
Best way to performance permutations
This has been my white whale for a while, the idea is convert all the symbols to the goal symbol using all the pieces.
I did an algorithm like 5 years ago (now is lost) and reach lvl 48 but got stuck ...
5
votes
2
answers
1k
views
Finding all possible letter combinations from an inputted phone number
Prompt:
Given a string containing digits from 2-9 inclusive, return all
possible letter combinations that the number could represent.
A mapping of digit to letters (just like on the telephone ...
1
vote
1
answer
1k
views
Function to generate all subsets of size n
The function works this way:
Set is an instance variable, and is an array of type generic.
nElement is the size of all the ...
1
vote
2
answers
2k
views
Subset sum simple iterative implementation
Here is the simplest iterative implementation of Subset sum problem that I could come up with1, as a follow up to this recursive implementation of the same problem:
...
5
votes
1
answer
657
views
Iterative implementation of K of N variations
Objective:
Print all combinations with repetition of k elements out of a set of n elements.
...
20
votes
2
answers
2k
views
Calculate all possible distributions of n objects to k containers
Let's say I have \$5\$ apples, thus \$n = 5\$. I have three bags (\$k = 3\$), each having the capacities of \$4\$, \$4\$ and \$2\$:
$$c = { \{4, 4, 2 \}}$$
I'd like to calculate the number of ways ...
6
votes
2
answers
209
views
How can I optimize this combination method?
I have this method that is working perfectly fine, but it's very slow, and sometimes I have to wait 15 minutes to get a good result, which is ok. I'm wondering if I can make it faster.
Basically I'm ...