Implement K queues in single Array C++

Here first we are going to understand the problem of how to efficiently implement K Queues in a single array, then we will discuss a solution and then finally we can implement the same in C++. Implement K stacks in single Array in C++ Problem: Create a data structure kQueues that represents k queues. Implementation … Read more

Find minimum number of distinct elements after removing M items

Here, we are going to find the minimum number of distinct elements after removing M number of items from array. Given: An array arr[] of items, an i‘th index element denotes the item id’s and given a number m. Problem: Remove m elements such that there should be minimum distinct id’s left and then print the … Read more

Program to find number of ways to distribute Objects

Here we’ll first understand the problem of calculation the number of ways to distribute objects into distinct groups, then we’ll implement the same in C++ with the help of example. Given: 2 integers N and R, where N is the number of objects and R is the number of groups. Problem: The task is to calculate … Read more

Program for K Most Recently Used (MRU) Apps in C++

GIVEN: Number k and an array arr[n], containing n number of integer elements which are storing the id’s of the opened apps in a system. PROBLEM: To print the contents of the array when the user using the system presses Alt + Tab exactly K number of times. The position of every id represents different apps in a … Read more

Find Root using Newton-Raphson method in C++

Newton-Raphson Method: The Newton-Raphson method (also known as Newton’s method) is a way to quickly find a good approximation for the root of a real-valued function f(x) = 0f(x)=0. It uses the idea that a continuous and differentiable function can be approximated by a straight line tangent to it. Newton-Raphson formula:               … Read more

Rearrange Array’s Even and Odd values in Ascending order C++

In this post we will understand the problem of rearranging the array’s even and odd values in Ascending order, then we will discuss the best possible approach and then write a C++ code to implement the solution. Let’s discuss the problem: Given: An array of integers with equal number of even and odd values. Problem: … Read more