Minimum number of subsets with distinct elements

Problem Statement Suppose you have an array of integers of size n. The problem statement asks to find out the minimum number of subsets with distinct elements, that is subsets that can be formed which contain all the different/distinct elements from the array. Example arr[] = {2,4,6,2,1,4,2} 3 Explanation: {1, …

Read more

Cumulative Frequency of Count of Each Element in an Unsorted Array

We are given an unsorted array. The task is to calculate the cumulative frequency of count of each element in an unsorted array. Example Input: A[]={2,4,3,2,2,3,4} Output: Cumulative frequency of 2 in the array is: 3 Cumulative frequency of 3 in the array is: 5 Cumulative frequency of 4 in …

Read more

Topological Sorting

Given a directed acyclic graph, topologically sort the graph nodes. Topological Sorting Example Topological sorting of above graph is -> {1,2,3,0,5,4} Theory Topological Sorting is done for a Directed Acyclic Graph (DAG). A DAG has no cycles in it. ie, there is no such path starting from any node of …

Read more

Translate »