This post on syntax errors in coding interviews was written by Michelle Bui. Michelle is a software engineer at Chime and a former engineer at Google and Intuit.
Walking into a technical interview as an engineer will make you nervous. Even if you've already nailed the perfect front end engineering resume or data science resume to get you this far, you're still not sure what to expect.
You're wondering whether you’ve prepared enough. What type of questions will the interviewer ask? Will your answer be clear and concise?
These are important to think about as you prepare for your upcoming software engineering interview.
Although, there is one common mistake that most engineers make and it costs them precious time in their interviews.
Syntax errors will slow you down.
Writing code at home is easy. You get error logs about missing semi-colons or misspelled variables.
A few seconds of going back to fix the issue isn't a big deal when you're in your pajamas.
But in a 30 or 45-minute coding interview, those seconds add up!
Not only can a minute or five pass by. You may uncover three new problems when you fix your variable name in one place.
The core logic of your code might be there. But if your interviewer calls time before you get to test it, it won't be a good look!
Even if you spent hours learning about recursion, BFS, DFS, or even iterating tw0-dimensional arrays, it will feel like a waste if you don't finish your application!
You know syntax errors are a problem, but how do you avoid them? By practicing, of course!
First off, you’ll need to recognize the most common data structures that are used in an interview:
For each of these data structures, practice initializing the data structure and accessing them without error in the language of your choice.
The common access methods you will need to learn are:
That means that for each of the three access methods, there are 9 data structures to work with.
That's 27 methods to learn and practice.
Secondly, you need to have a coding environment that will help you get started quickly.
Avoid needing to install a programming language. Avoid having to set up any boilerplate code like creating the main function.
Focus on the data structures themselves.
If you feel comfortable with your terminal, go ahead and use it.
A simpler option is using a free online coding editor where you can run your code.
Do not use an IDE or code editor that has autocomplete. It will suggest method names to help you code.
As a result, you will miss the opportunity to reduce your syntax errors. In a real interview, you cannot rely on autocomplete.
Third, you need to pick a data structure to start practicing.
Practice how to:
If you’re not familiar with the data structure and its associated methods, you can search online for sample code.
While looking for coding examples, pick one that is easy to follow!
Pick an example that runs without error and use it for practice.
Below is an example of how to find sample code for Java. It uses the data structure "list."
After Googling, “How to Initialize List Java,” the sample code given looks like this.
Running this example in a coding editor works! The full example is below:
Another Google search for “How to add to list Java,” and you'll find the below code:
You may find differences in the variable name and initialization as you search for examples.
For now though, find code that is simple and compiles easily. Get started practicing sooner!
A final Google search for “How to remove from list Java” results in the following code.
Just like other examples, don't worry about making it all match right away.
You may start to notice some differences in the results of each search. Data structures may have different types (string or integer).
For now, it's not important to focus on. As long as the code compiles, you're in good shape!
The goal is to focus and eliminate any distractions so you can get to coding quickly and practice without making any errors.
Lastly, I search “How to lookup item in list Java” and decide to use this example:
Now, with working samples for a List data structure, you can finally get to practicing!
The goal here is to write the code over and over again to remember the name of the methods and the syntax.
Type out the example code character by character until you feel comfortable with the data structure.
The last thing you’ll need to do to truly measure whether you can code without syntax errors is to remove the example and write the code on your own.
Yet again, you'll write the code to initialize the data structure. Then, you'll write code using the methods you’ve been practicing:
Keep practicing until your code compiles flawlessly!
After you've gone through basic data structures, see if you can code without any errors. Work through practice problems.
Start with easy ones that don't require much thought and move up to harder ones that you need to focus on. As you ramp up the difficult, do you notice more syntax errors?
Syntax errors slow many engineers down in interviews.
I’ve conducted more than 1,000 coding interviews and syntax errors are the single most common mistake I see. - Michelle Bui (Software Engineer, Chime)
You should be spending the majority of your interview time talking about the logic and algorithm. Don't waste it fixing syntax errors that are easily avoidable.
Stay ahead by coding common data structures without error. Pick the simplest syntax to practice those data structures.
The most common syntax issues are usually
They are little errors but they can eat away at your interview time if you're not careful!
As you can imagine, you'll need more than just syntax practice to set yourself up for the best success in your upcoming interview.
But don't fret. Here at Exponent, we have numerous different interview resources that will help put you in the best possible position to ace your software engineer interview:
💬 Practice with sample Software Engineer interview questions
📖 Read through our Software Engineering interview guides
👯♂️ Rehearse your behavioral and interpersonal skills with our interview practice tool.
👨🎓 Take our complete Software Engineering interview course.
Exponent is the fastest-growing tech interview prep platform. Get free interview guides, insider tips, and courses.
Create your free account