An IMPOSSIBLE task actually says “I M POSSIBLE”

Dynamic programming(DP) is an algorithmic technique that is used for the optimization of problems that have a recursive solution. Usually whenever we apply a recursive solution for a problem there exists a problem of overlapping subproblems. This means while recursion breaks down the problem into smaller bits sometimes it calculates the result of the same subproblem again and again even though if the solution was calculated before. This is a result of not storing the results of the subproblems.

This is where dynamic programming holds the advantage. The results of the subproblems are stored in a data structure like 1D or 2D arrays. This also results in a decrease in the time complexity compared to the recursive solution. This approach of using a data structure to store the results of already calculated subproblems is called memoization. In this blog, we’ll be seeing more about this algorithmic technique by seeing some of its practical applications along with solving and analyzing one of the most famous questions in dynamic programming “Best time to buy and sell stocks with cooldown”. …

Strings are an important concept to cover when it comes to interview-preparation for many companies. In this article, I plan to cover the concepts of string also providing its real-life application along with the solution of a problem on LeetCode based on the above concepts. So let’s get started!

There are two ways to hold a sequence of characters in C++. They are

- Using character arrays
- Using strings

Remember these both are not the same, the difference lies in the fact that character arrays are of the data type character whereas a string is a class that defines objects that can be represented as a string of characters. One more difference lies in the size allocation. Size allocation is static in the case of character arrays whereas it's dynamic in the case of strings. …

Stacks are one of the most common data structures which can be seen to have the most daily life applications. As the term defines stacks can be imagined as a pile of books stacked upon each other. Stacks is a linear LIFO data structure, where the term LIFO defines last in first out. This means the element which is inserted at last will be the first one to go out. This can also be imagined by taking the example of the books pile. If we want to take a book from the middle it will be a little tough to take it out directly as it may lead to other books collapsing, hence to avoid this we start taking a book from the top, which means the book which was inserted at the end was the first to be taken out. …

Computer science is full of real-life examples. One such example is the linked list. A linked list is a data structure that has nodes attached. Now one may ask what is the difference between a linked list and an array. The difference lies in space consumption. A linked list is a noncontiguous data structure hence it ensures more optimized usage of space than an array. Similar to how an array consists of elements a linked list consists of nodes. Each node is divided into two parts

- Data part
- Pointer part

The data part in a linked list stores the value being held in the node while the pointer part holds the pointer to the next node so that the non-contiguous property of the linked list is ensured. …

Two pointers is an algorithmic technique used for the optimization of many other algorithmic problems. It can be also told as a subset of the binary search algorithm. We can see two pointers apply when we are passing data from non-privileged to the privileged mode in the OS context, traversing linked lists to find its midpoint, or to reverse a linked list. This makes two pointers an important concept to be covered before we proceed to further topics like linked lists, binary search trees, etc. Let’s understand a little bit more about 2 pointers with a problem from Codeforces.

Eugene likes working with arrays. And today he needs your help in solving one challenging task. …

Binary search is one of the most optimized search methods. It has thousands of applications. Some of the small applications might include searching the following vs follower list on Instagram to find people whom you follow and who don’t follow you back, autocompletion of searches in chrome and other browsers, etc.

Today we are going to look at a clever application of binary search algorithm by solving a problem called “The magnet array problem”.

Given n Magnets which are placed linearly, with each magnet to be considered as of point object. Each magnet suffers force from its left-sided magnets such that they repel it to the right and vice versa. All forces are repulsive. The force being equal to the distance (1/d, d is the distance). Now given the positions of the magnets, the task to find all the points along the linear line where the net force is ZERO. …

Hey guys, it’s me DiligentCoder with yet another algorithmic article. I'm really sorry for the delay as this was a pretty hectic week, but none the less I’m back with an amazing problem and an even more amazing algorithm to crack the problem. So without any further delay let’s start the discussion.

*Problem:*

The problem tells us that we are given a histogram with non zero height bars and zero bars in between ( zero bars in between aren’t necessary) as given in the above figure. The heights of each bar are represented with the help of an array. Assume each bar as a building. …

Hey guys, it’s me DiligentCoder with yet another article on algorithms this time specifically on bit masking, where I’ll cover some basic concepts and move on to the one algorithm which I had dealt with and found to be really beautiful. Let’s hence proceed to the basics without wasting any further time.

*WHAT ARE BITMASKS?*

Bitmasks are a small set of boolean values(0 or 1). We all know that integers are stored in the computer as boolean values and not as such as it is. Operations dealing with bitmasks and boolean values are termed as bit manipulation. …

Hey guys! My name is Siddharth also known as DiligentCoder in many coding platforms. I ‘am currently pursuing my bachelors degree in Computer science. Algorithms are tough and that’s what makes it interesting to crack and solve them. I ‘ am currently writing this blog as a complete fresher with only some knowledge in algorithms but at the same time preparing each day and sharing the tough problems encountered over here along with it’s explanation so that everyone around also gets to know about that particular problem and the approach used. …