Tag Archives: STL

Graph implementation using STL for competitive programming | Set 1 (DFS of Unweighted and Undirected)

We have introduced Graph basics in Graph and its representations. In this post, a different STL based representation is used that can be helpful to quickly implement graph using vectors. The implementation is for adjacency list representation of graph. Following is an example undirected and unweighted graph with 5 vertices. Below is adjacency list representation… Read More »

Count pairs whose products exist in array

Given an array, count those pair whose product value is present in array. Examples: Input : arr[] = {6, 2, 4, 12, 5, 3} Output : 3 All pairs whose product exist in array (6 , 2) (2, 3) (4, 3) Input : arr[] = {3, 5, 2, 4, 15, 8} Output : 2 A… Read More »