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

Merge Overlapping Intervals

In merge overlapping intervals problem we have given a collection of intervals, merge and return all overlapping intervals. Example Input : [[2, 3], [3, 4], [5, 7]] Output: [[2, 4], [5, 7]] Explanation: We can merge [2, 3] and [3, 4] together to form [2, 4] Approach for finding Merge …

Read more

Wiggle Sort

Wiggle Sort!? All my readers must’ve found the name of today’s problem very funny. However, it is a very smart problem that tests our understanding of a varied range of concepts. Let us jump straight to the problem without any further confusion. Example You have an array Input: [1,5,1,6,4] Expected …

Read more

Search in Sorted Rotated Array

An element search in sorted rotated array can be found using binary search in O(logn) time. The objective of this post is to find a given element in a sorted rotated array in O(logn) time. Some example of a sorted rotated array is given. Example Input : arr[] = {7,8,9,10,1,2,3,5,6}; …

Read more

Translate »