**Difficulty:** Medium

**Asked In:** Google, Facebook, Microsoft, Amazon, Flipkart, Hike, Morgan Stanley

- Brute force approach using nested loops
- Using sorting and binary search
- Using sorting and two pointers approach
- Efficient Approach using a Hash Table

- A famous searching problem that can be solved using various approaches.
- The two-pointers and Hash Table solution are worth exploring.
- One can find variations of this problem asked during a coding interview.

Given an array of n integers and given a number **targetSum**, write a program to determines whether there is a pair of elements in the array that sums to exactly **targetSum**.

- We assume…

**Asked In**: Google, Microsoft, Adobe, SAP Labs, Goldman Sachs, Qualcomm

Quick Sort is one of the most popular algorithms that uses a divide and conquer problem-solving. Here are some excellent reasons to learn this algorithm —

- Often the best practical choice for sorting because it is remarkably efficient on average. It is an in-place sorting algorithm that also works best in the virtual memory environment.
- One of the best algorithms to learn the idea of recursion in programming. Its recursive structure, the flow of recursion, and the base case are intuitive.
- A good algorithm to learn the worst, best, and…

Computer science is a field of dream opportunities. All over the world, millions of students are looking forward to pursuing a career in the field of computer science. Though a lot of learning resources are available online, still, most of the students are struggling to become good at it and crack the interview. After working closely with more than 1k students, here I would like to highlight the top 5 learning challenges in computer science.

Solving problems is a practical skill like, let us say, swimming. We acquire any practical skill by imitation and practice. — George Polya

**But before…**

To solve a problem, sometimes it is necessary to repeat a particular code statement several times (possibly doing some key operations at each repetition) until a specific condition is satisfied. It is known as iteration, which allows us to “write code once” and “execute many times.”

The idea of a loop helps us provide the flexibility of code reusability to simplifies complex problem solving, i.e., instead of writing the same code, again and again, we can execute the same code a finite number of times. Think! There are two types of loops mostly used in programming:

We use “for” loop…

**Input:**An array X[0 . . . n-1] of n integers**Output:**A permutation (reordering) of input such that X[0] <= X[1] <= X[2] …. <= X[n-2] <= X[n-1]

Sorting is one of the fundamental problems in algorithms and data structure. But the critical question is — why we study the design and analysis of the sorting algorithms? Here are some critical reasons:

- Various problem-solving approaches can be best understood using sorting algorithms:
**incremental approach**(selection and insertion sort),**divide and conquer**(merge and quicksort),**two pointers**(merging and partition),**problem-solving using a data structure**(heap sort), etc. - Sorting algorithms…

**Difficulty:** Easy

**Asked in:** Google, Amazon, Adobe, Oracle, Qualcomm, SAP Labs, Wipro

Given a sorted array X[] of n elements, write a program to search a given element **key** in X[]. If the key exists, then we need to return its index in the sorted array. Otherwise, return -1.

- All the integers in X[] are unique.
- X[] is sorted in ascending order.

Input: X[] = [-4,2,4,5,9,12], key = 5

Output: 3

Explanation: 5 exists in X[] and its index is 3.Input: X[] = [-4,2,4,5,9,12], key = 6

Output: -1

Explanation: 6 does not exist in x[] so return -1

…

Thank you panner dass. Your appreciation works as a motivation for me. Enjoy learning.

Recursion means “ solving the problem via the solution of the smaller version of the same problem” or “defining a problem in terms of itself”. It is a widely used idea in programming to solve complex problems by breaking them down into simpler ones. In this blog, we’ll go over the basics of recursion and help you to refine an essential programming skill.

Recursion comes up in mathematics frequently, where there are many examples of expressions written in terms of themselves. Calculating the value of nth factorial and nth Fibonacci numbers is the best example of this. …

Before the invention of computers, there were algorithms. Now computers are everywhere, so algorithms are everywhere! Algorithms lie at the heart of computing. If we observe our surroundings, we can find several algorithms working to solve our daily life problems. Social media Networks, GPS applications, google search, e-commerce platforms, Netflix recommendation systems, etc. applications are powered by algorithms. Even it is also popular during the coding interview to get a high-paying job in the software industry. So learning algorithms is one of the critical career skills for programmers.

Most developers need to realize the importance of data structure and algorithms as early as possible in their career. The reason would be simple: knowledge of this subject helps us grow as better programmers and master computer science. On another side, the interviewer uses DSA to test programmers during the coding interview. It provides them a simple approach to evaluate problem-solving skills, basic computer science knowledge, clarity of thought, and analytical skills.

But mastering algorithms and data structure requires motivation, proper guidance, hard work, and a continuous learning plan. …

A learner who enjoys problem-solving in Computer Science | Founder at EnjoyAlgorithms | Super 30 | IIT