Preparation, practice and persistence- this is how you succeed in coding interviews.
The two kinds of coding problems
1. Actual Coding: You have to write clean, efficient code for a given problem.
2. Chitchat: You give answers to interviewer's question. You may be asked a knowledge question ('what is ...', 'What is the difference between...') Or, you may be asked a high level question (e.g. 'How can one beat Facebook?', 'How can links work inside mobile apps effortlessly?' etc.
The chitchat questions are meant to see if you really know stuff about coding, if you take initiative (fixing patchy code without even being asked, and if you solved a technical problem or two, how well you can take them through the process (the good old PAR format- Problem, Action and result)
Go prepared: Have examples ready (example of interesting tech problem/s you worked on, example of how you are with people skills- leadership, teamwork, conflict resolutions, dealing with deadlines etc.). Of course you have done research about the job description, the company, the competition, programming languages they do most work on and son on.
When given a problem, take your time before you do anything
Tell them straightaway if you don't know at all- 'I have never worked on X language.' Even if you know the answer, and you have to write it down, take time with your logic. Don't rush into things.
You may have to write the code with pen and paper (or on a whiteboard)
At least, practice your handwriting.
First get your logic in line
First, just work through the problem, the logic and everything. Syntax, details...that's for later. At start, you can leave white space after some lines of code for later stuff, as you work through the problem. Fill that up later.
Use descriptive variable names.
This also shows you not only care about the logic, you also care about how readable (and thus editable) your code is.
Work through the solution out loud
Talk out your solution- variables used, the logic, the what ifs, the possible error situations...they want to look at your process. Also talk about how your code would work with edge cases, and about unit tests.
Don't mind when you get stuck
Just focus on the logic. Moreover the interviewer is more interested in your logic and process than how many times you got unstuck.
When you get unstuck, think on the board
Pictures, simpler version of the problem, etc. It is okay to come up with an inefficient solution, as long as you know about it, tell about and try to refine later.
When you get unstuck, just think it out aloud
Focus on why you thought it would have worked, and why now it didn't work. Hearing yourself, putting the problem out there, helps look at it with different perspective.
When you think aloud, this may be when your interviewer, seeing you all so involved with the problem, give a hint.
Do the checking in the end
Remember, algorithm first, everything else, later.
Do a lot of practice questions beforehand
Google 'coding interview questions'. Make the search more specific by adding in a language or technology. If it is a big company, add in the company name to the search term - 'Android app coding interview questions', php coding interview questions', 'Microsoft coding interview' and so on.
Questions to ask the interviewer
Apart from the questions about the usual day-to-day job, challenges, the company and the competition, ask about the 'tech stack' it works on (programming languages, server setup, databases etc.), and about the organization setup regarding team structure and size, and also about the key result areas for the job.
Thank you for reading.
This guide is from The Success Manual, which contains 200+ guides to succeeding in business, career and personal life. Get the pdf ebook for $12 only.