The most common coding interview questions (and how to answer them)

in #coding2 years ago

A programming interview can be a nerve-wracking affair, but it doesn’t have to be! If you’re preparing for an interview at the company of your dreams, it helps to know the most common programming interview questions and how to answer them. This article has all of that information and more! Check it out to learn everything you need to know about the most common coding interview questions and what to do when you don’t know the answer right away.

Debugging

There are no stupid questions. In fact, one of your job is to ask a lot of questions. If you can’t think of any, just tell your interviewer that and ask what they would like you to know about their company and position. Do not worry if you don’t know all or even any of these concepts. You are here to learn as much as possible so don’t hesitate to inquire about anything you do not understand. Answering I don’t know is okay and will show humility on your part. But try to make sure it doesn’t happen too often. When in doubt, fake it till you make it. It is perfectly acceptable to say something like I have never used X before but I am familiar with Y and Z which seem similar enough for me to grasp quickly. This shows confidence and experience in your field while still leaving room for growth. And finally, please do not panic! No matter how badly you perform, there is always another opportunity out there waiting for you. The worst thing that could happen is someone saying no to an offer. At least now you know where you stand and can move forward from there. Best of luck to you all!

Picking an algorithm

Often, you’ll be asked to pick an algorithm and implement it in code. If possible, try implementing several different types of algorithms, since there are many ways to solve a problem. Here are some common algorithms that might show up on your next coding interview:
How would you sort a million numbers? Which sorting algorithm would you use? Explain your choice. How would you search for something in an unsorted list of one million numbers? Explain your choice. How would you reverse a string? Explain your choice. How would you find if two linked lists have equal elements? (Note: both lists must be sorted.) Explain your choice. How would you check if a binary tree is balanced? Explain your choice. How would you compute Fibonacci numbers without using recursion or loops? Hint: think about memorization and divide-and-conquer algorithms. What’s another way to say divide and conquer? What are some applications of divide-and-conquer algorithms that aren’t related to computing Fibonacci numbers? Why do we care about divide-and-conquer algorithms, anyway? If I gave you a large data set, how would you store it so that finding specific pieces of information was as fast as possible? Explain your choices. If I gave you a large data set, how would you store it so that reading through it sequentially was as fast as possible? Explain your choices. If I gave you a large data set, how would you store it so that searching through it randomly was as fast as possible? Explain your choices. You’re given a function called merge sort() . It takes in an array of integers and returns another array containing those integers sorted. Describe what happens when you call merge sort() on any array. You’re given a function called merge sort() . It takes in an array of integers and returns another array containing those integers sorted. Describe what happens when you call merge sort() on any array with duplicate values at different indices.

Identifying bottlenecks

Bottlenecks are a feature in our code. They cause unexpected errors and break our applications. One of our primary tasks as programmers is to identify bottlenecks and eliminate them. So how do we know if there’s a bottleneck? One way to detect whether or not there’s a bottleneck is by checking if some parts of our application run slower than others. If so, it’s very likely that we have a bottleneck issue somewhere in our code. The best way to go about identifying these bottlenecks is by testing different scenarios with different types of data. For example, let’s say we want to find out if there’s a bottleneck when processing large amounts of data. In order to test this, we could create two groups: one group with small amounts of data and another group with large amounts of data. We would then compare how long each group takes to process its respective amount of data. If both groups take roughly around the same time to process their respective amounts of data, then we can conclude that there’s no bottleneck present. However, if one group takes much longer than expected to process its data, then we can conclude that there’s a bottleneck present somewhere in our code—most likely due to insufficient memory allocation or inefficient algorithms. This process will help us identify where exactly there’s a bottleneck and what type of data causes it. Once we’ve identified where exactly there’s a bottleneck, we can then try to fix it using various techniques such as refactoring our code or implementing more efficient algorithms.

Testing, testing, testing

If you’re interviewing for a position as a developer, you should expect to be tested on your technical skills. Before you enter an interview room, know what language(s) and tools are being used. Is it C#? Java? Python? Understand which version of each is in use and go into each interview ready to code. See our tutorial How To Ace A Coding Interview: Tips From The Pros for more advice on acing these tests. Remember that if you don’t know something, say so! You have nothing to lose by admitting that there’s something about a question that’s beyond your current abilities. Your interviewer will appreciate your honesty and give you time to do some research before moving forward with other questions. In many cases, they’ll even offer to help point you in the right direction! Don’t get caught up trying to fake knowledge—it can only hurt you in the long run. Rather, find ways to demonstrate that you’re hungry for learning new things and willing to put in effort toward self-improvement. This could mean reading books or blogs about topics outside of your comfort zone or taking free online courses from top universities like Stanford University or Harvard University. There are also countless free tutorials available online from industry leaders like Google at sites like Udacity, Coursera, and EdX. But don’t stop there! Once you’ve got a good grasp on material relevant to a particular job opening, try doing some mock interviews with friends who work in those fields—they’ll be able to tell when you’re giving canned answers versus demonstrating real mastery over a subject matter. And remember, practice makes perfect!

Designing data structures

You’ll also want to practice designing data structures. There are a number of resources available that can help you with this, but one of my favourites is Data Structures and Algorithms view more...

Java, C++ or Python?

Using regex

System design questions

Coin Marketplace

STEEM 0.36
TRX 0.12
JST 0.039
BTC 69735.97
ETH 3533.64
USDT 1.00
SBD 4.72