Coding challenges
So far, we've covered the most popular sorting and searching algorithms that are encountered in technical interviews. It is advised that you practice these algorithms since they may occur as standalone problems that require the pseudocode or the implementation.
That being said, let's tackle 18 problems that are related to sorting and searching algorithms.
Coding challenge 1 – Merging two sorted arrays
Amazon, Google, Adobe, Microsoft, Flipkart
Problem: Consider you've been given two sorted arrays, p and q. The p array is large enough to fit q at the end of it. Write a snippet of code that merges p and q in a sorted order.
Solution: It is important to highlight the fact that p has enough space at the end to fit q. This suggests that the solution shouldn't involve any auxiliary space. The solution should output the result of merging p and q in a sorted order by inserting the elements from q in p in order.
Mainly, we should...