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.
Input: X = [-4,2,4,5,9,12], key = 5
Explanation: 5 exists in X and its index is 3.Input: X = [-4,2,4,5,9,12], key = 6
Explanation: 6 does not exist in x so return -1
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 —
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
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…
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:
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. …
Google, Facebook, Amazon, Adobe
Given an array of n non-negative integers height [n], where each value represents a point at coordinate (i, height[i]). Now n vertical lines are drawn such that the two endpoints of line i are at (i, height[i]) and (i, 0). …
A learner who enjoys problem-solving in Computer Science | Founder at EnjoyAlgorithms | Super 30 | IIT