Founder and CEO at EnjoyAlgorithms | Super 30 | IIT BHU | Mentoring Youth for Success

Easy

Google, Amazon

Given an array X[] of n integers, return true if and only if it is a valid mountain array. The array X[] is a mountain array if and only if n >= 3 and there exists some i with 0 < i < n — 1 such that:

- X[0] < X[1] <…X[i-1] < X[i]
- X[i] > X[i+1] > …> X[n — 1]

In other words, we call the array mountain array when the array is strictly increasing and then strictly decreasing.

Input: X[] = [5, 2, 1, 4]

Output: falseInput: X[] = [5, 8, 8]

Output…

Medium

Facebook, Microsoft

- Brute force approach — Using single scan (Increasing the loop by 1)
- Divide & Conquer approach — Idea similar to merge sort
- Efficient Approach — Using single scan (Increasing the loop by 2)

- A good coding interview problem to understand single scan and divide and conquer approach of problem-solving.
- We are incrementing the loop by two (or constant) to optimize the code further. We can use a similar idea to optimize other coding problems.
- Base conditions, initialisations, and if statements are intuitive.
- The time complexities of all three approaches are O(n), but the total comparison count is…

Algorithmic Thinking has recently become a buzzword among programmers. It is a method for solving problems based on a clear definition of the steps: logically and repeatedly. The best idea would be to develop this skill independently from learning programming, where proper visualisation can help us understand several efficient problem-solving approaches.

- Do we understand every word used within the problem?
- What data or information are provided as input?
- What data or results are requested as an output?
- Understanding and extracting computational and non-computational details relevant to the problem — data structures, particular instances of the problem, the general cases of…

The data structure and algorithm provide a set of approaches to the programmer for handling the data efficiently. If the programmer does not know about data structure and algorithm, they may not write efficient and correct code for their software. It is a fundamental building block of computer science and critical for career success. Let’s understand its importance from two different points of view —

**Career point of view — **The data structure and algorithm can be used to test both freshers and professionals in the tech industry. …

Easy

Facebook, Amazon, Uber, Bloomberg, Linkedin, Paytm

- Brute Force Approach — Using extra space
- Using two pointers approach — Double scan
- Using two pointers approach — Single scan

- The efficient solution is a variation of two pointer approach where pointers are moving in the same direction.
- A good problem to learn optimisation by improving the space complexity and reducing the extra traversal.
- We can use similar ideas to solve other coding problems.
- A good problem for beginners to start coding.

Given an array X[] of n elements filled with several integers, some of them being zeroes, write a program to…

Let’s discuss something important: how to prepare a learning strategy to achieve interview success? Here is a step-by-step guided strategy:

The first step would be to develop a long term desire to achieve the target. We should think — why I want to accomplish this? How will it change life in the long run?

Suppose we have 6 months’ available duration with a commitment of 5 hours/daily. Then the total time = 30 x 6 x 5 = 900 Hours. Let’s do the round-off and say, we have 1000 preparation hours in 6 months. Similarly, we have 2000 preparation hours…

Most programmers need to realize the importance of data structure and algorithms as early as possible in their careers. The knowledge of this subject helps us grow as better programmers with problem-solving in computer science. We should never develop a belief to consider this merely a subject because it is much more than that! Think.

Why tech companies test the knowledge of Data structure and algorithm during the interview process? The answer is obvious — these companies encounter problems daily that are complex and large on the scale of data, and they would like to hire a smart programmer who…

Medium

Microsoft, Amazon, Goldman Sachs, Qualcomm, Bloomberg, Paytm

Merge sort is a popular sorting algorithm that uses a divide and conquer approach to sort an array (or list) of integers (or characters or strings). Here are some excellent reasons to learn this algorithm -

- An excellent algorithm to learn recursion and its analysis using recursion tree method and master theorem.
- One of the efficient
**comparison-based sorting**algorithms that work in**O(nlogn)**time complexity in the worst case. - The best algorithm for sorting linked lists, i.e., it can sort the linked list in O(nlogn) time complexity in the worst case.
- We…

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…**