The best programs are written so that computing machines can perform them quickly and so that human beings can understand them clearly. A programmer is ideally an essayist who works with traditional aesthetic and literary forms as well as mathematical concepts, to communicate the way that an algorithm works and to convince a reader that the results will be correct. ― Donald E. Knuth

# Algorithms

## Introduction

Designing an efficient algorithm to solve a problem in computer science is a skill which makes you a real geek. This is a skill which tech firms like google, microsoft, amazon, adobe, yahoo and many others look at in their interviews. Once u are comfortable with a programming language, the next step is to write efficient code to solve problems of different levels of difficulty. That said, thinking of an efficient algorithm is independent of programming language. Algorithms are simply a set of instructions followed in a logical order to solve a problem. It existed even before first programming language originated.

Let's get back to the point. One needs to have a decent knowledge of a programming language to implement the generic solution to a problem. Efficiency in terms of time and memory is the most vital part of any algorithm. It is measured and represented with the term 'complexity'.

On a brief note, if we are given an input data set of size n, and we need to iterate over each element of the set once to solve a problem with the given set, the complexity is O(n) or Order(n) ['O' is known as "big oh" notation]. For e.g, there are 6 elements { 5,2,7,8,1,3 } i.e n = 6. To find the largest no., we have to visit each element once. So it's complexity is O(n). There are other notations to express complexity which we will cover in some other sections. But the point is we should try to think of best possible way to solve a given problem. Suppose you are getting interviewed by any of the firms mentioned above, if you give a naive approach for a problem, the follow up question will definitely demand an efficient approach.

So, with all these points in mind, let's get motivated to see some efficient approaches for some algorithmic problems. The set of problems solved here is not an exhausted list but it will give an idea to think efficient algorithms and implement it. All solutions are implemented with C++. They can be simply copy pasted and run. Please subscribe to our newsletter to remain updated with the problems that we add at regular intervals.

Ok then, let's not get overwhelmed with more theory, and get practical and orient ourselves towards problem solving . Thus, understand the problems, try to think of best possible approach to solve it before seeing the solution, gain more and more confidence, become a geek, crack the coding interviews and make it big .....

Next