Source Code

 
Coding questions and their source code

 

detect graph cycle

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

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 ...
generate valid parentheses

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 listing

Build hierarchy tree

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

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 ...
Tournamnet ranking

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 bidirectional bfs

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 java

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 ...
dominoes euler path

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

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 ...

 

Comments are closed