Graph: Given a graph with source and destination, count all the possible path between two vertices
Problem Statement: You are given a directed non cyclic graph, and 2 nodes having source and destination. You need to return the count of two…
Graph: Given a graph, check if it is bipartite or not – Using BSF
Problem Statement: You are given a graph with the number of vertices and list of edges. You need to check if the graph is bipartite or not. A…
Graph: Given course with prerequisites, find the order of taking the courses
Problem Statement: You are given n courses, labeled from 0 to n-1 and prerequisites[][]. prerequisites[i] = [x, y], meaning you should take…
Graph: Check if the given courses can be completed with prerequisites
Problem Statement: You are given n courses, labeled from 0 to n-1 and prerequisites[][]. prerequisites[i] = [x, y], meaning you should take…
Graph: Find the number of Islands
Problem Statement: You are given a n * m matrix, where ‘w’ is water and ‘l’ is land. You need to count the number of…
Graph: DFS graph traversal
Graph: DFS graph traversal DFS stands for Depth First Search. In this we will traverse adjacent vertices one by one. This is similar to…
Binary Search Trees: Given a BST, find the second largest element in the BST
Problem Statement: Given a BST, find the second largest element in the BST Example Input: /* * 10 * / \ * 8 12 * / \ / \ * 2 9 11 14 */…
Binary Search Trees: Given 2 BST, print common nodes in the BST
Problem Statement: Given 2 BST, print common nodes in the BST Example: Input: /* * 10 * / \ * 8 12 * / \ / \ * 2 9 11 14 */ /* * 10 * / \ * 8…
Binary Search Trees: Given a sorted array, convert into balanced bst
Problem Statement: Given a sorted array, convert into balanced bst Example: Input: arr = [1, 2, 3] Output: /* * 2 * / \ * 1 3 */ Solution…