Coding questions and their source code

Detect cycle and remove cycle in directed graph
A graph is a data structure that consists of a set of nodes (vertices) connected by edges. A graph is ...

Modulo operation and circular array
The modulo operation returns the remainder of one number divided by another. Modulo operator is a arithmetical operator, represented as ...

Combinations of adding valid parentheses
To find number of possible combinations of valid parentheses, we have to know Catalan number. Catalan numbers are a sequence ...

Build hierarchy tree
Build hierarchy tree is to build a corporation hierarchy tree from an employ list. HashMap plays important role to store ...

Josephus problem using circular linked list
"Josephus problem" or "circle of death problem". Given a number n people standing in a circle, eliminate every kth one ...

Topological sort using DFS and BFS
Topological sort is a graph traversal in which node v is visited only after all its dependencies are visited. The ...

Word ladder using bidirectional BFS
Word ladder is to find the number of steps to convert one string to another by changing one letter at ...

Autocorrect and edit distance problem in Java
When you search in Google, it provides autocorrect for validating the keywords you enter into the input box. Behind the ...

Domino Eulerian path problem using backtracking
A Euler path (Eulerian path) is a path in a graph that you visit each edge exactly once. You can ...

Permutation of multiple arrays and iterator – code
Permutation of multiple arrays and iterator has two tasks. First is the permutation of multiple arrays and output as an ...