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

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