All Questions
48 questions
0
votes
0
answers
114
views
Generating group permutations: an extended Heap's algorithm in Java
Suppose we have a sequence of sequences <1, 2> <3, 4>. There, we have two groups: <1, 2> and ...
3
votes
1
answer
163
views
String Permutation Implemention
The objective is simple: List all possible permutations for a given a String. I looked at some implementations from popular sources. I decided to build this to the flow:
The Code for Review
...
1
vote
1
answer
228
views
Creates all possible permutations of a string and its substrings
I want to improve this code to efficiently create all possible permutations/combinations of a string. For example, if I have the string "abc", the result would be the list [ab, ac, ba, bc, ...
2
votes
0
answers
124
views
Iterating over all simple unique cycles in an undirected graph in Java - brute-force approach
This post is about an Iterator iterating over simple loops of an undirected graph.
In the above graph, the cycle \$\langle 1, 2, 3, 4, 5, 3, 1 \rangle\$ is not ...
3
votes
1
answer
111
views
Building a tree containing all permutations of arithmetic expressions given some numbers
Given any series of numbers, for example 1,2,3,4,5 and given the arithmetic operands + - * / including parenthesis, what would be the most optimal way to build a tree that contains all permutations ...
7
votes
5
answers
736
views
String combinations of 0 and 1
I was asked this question in an interview:
Given a string s consisting of 0, 1 and ...
5
votes
5
answers
1k
views
Checking if an integer permutation is cyclic in Java
A an integer permutation array[] is said to be cyclic if and only if we can choose an arbitrary element at position i, move it ...
3
votes
2
answers
1k
views
Print out all possible letter combinations a given phone number can represent
I am working on a problem in which given a 7 digit telephone number, we need to print out all possible combinations of letters that each number could represent.
I came up with below code and I was ...
3
votes
1
answer
603
views
Bovine Shuffle using a queue (USACO Dec 2017 Silver)
I am working on the "Bovine Shuffle" problem from the December 2017 USA Computing Olympiad, and have got it to work for every test case beside two. When I run these two cases on my own computer, they ...
5
votes
3
answers
6k
views
Generating all possible combinations of a string using iteration
I am generating all possible combinations from a string concatenated. I have a \$O(n*2^n)\$ solution.
...
3
votes
2
answers
1k
views
HackerRank challenge to count ways to climb a staircase, solved using Java Fork Join
I'm trying to solve Stair case recursion problem on HackerRank. The problem is to find all possible ways for a child to climb a stair case with height n given that ...
1
vote
1
answer
126
views
Count all possible attendance records with length n, which will be regarded as rewardable
Given a positive integer n, return the number of all possible attendance records with length n, which will be regarded as rewardable. The answer may be very large, return it after \$\mod 10^9 + 7\$.
...
0
votes
1
answer
436
views
Produce the nth lexicographic permutation of a string consisting of letters H and V
I have tried many possible methods here but I am still not able to reduce the time complexity of below algorithm.
...
1
vote
1
answer
131
views
Producing residues of combinatorics on strings
Basically, this code does multiplication of chosen operations.
...
2
votes
1
answer
997
views
Generating all unique permutations of a string
Here is a plan for generating the permutations of S: For each item x
in S, recursively generate the sequence of permutations of S - x, and
adjoin x to the front of each one. This yields, for each ...