Maximum points from top left to bottom right of Matrix

Given: Matrix of size MxN, consists of ‘#’, ‘.’ and ‘*’, where: # means blocked path . means walkable path * means points to collect. Problem: To find the maximum points you can grab to reach bottom right of the matrix from top left. Consider you are at the top left of the matrix, you have … Read more

Highway Billboard Problem: Dynamic Programming

In this post we will understand the problem of Highway Billboard Problem and then we will implement the solution using Dynamic Programming. Problem: Let’s suppose we got a job to place billboards (advertising hoarding) on a National Highway of length M miles. The possible site for billboards are given by numbers x1 < x2 < ….. < … Read more

Find length of the longest sub-sequence in C++

In this post first we are going to understand the problem to find the length of longest sub-sequence of an array and then we will write a C++ program to implement the same. Let’s understand the problem first: Given: An array arr[ ] of N integers. Problem: To find the length of the longest subsequence … Read more

Implement K stacks in single Array C++

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

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 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 number … Read more