3.2. Solving the Questions
Now it's time to solve the questions, but don't just jump in. Instead, remember you want to fully understand the problem. You should try an example, and then focus on the algorithm that will solve the problem. You then want to explain your solution and code for the solution. The following steps walk you through the process:
3.2.1. The Basic Steps
The best way to solve an interview problem is to approach it methodically. Here are the suggested steps:
Make sure you understand the problem. Your initial assumptions about the problem may be wrong, or the interviewer's explanation may be very brief or difficult to follow. You can't demonstrate your skills if you don't understand the problem. Don't hesitate to ask your interviewer questions about the problem, and don't start solving it until you understand it. The interviewer may be deliberately obscuring things in order to determine whether you can find and understand the real problem.
Once you understand the question, try an example. This example may lead to insights about how to solve the problem or bring to light any remaining misunderstandings that you have. Starting with an example also demonstrates a methodical, logical thought process. Examples are especially useful if you don't see the solution right away.
Make sure you understand the problem before you start solving it, and then start with an example to solidify your understanding.
Focus on the algorithm you will use to solve the problem. Often, this ...
Get Programming Interviews Exposed: Secrets to Landing Your Next Job, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.