Technical Questions - Overview
Technical questions are probably the most significant and basic part of an interview related to IT or computer science (CS) fields. In this chapter, we are going to talk about such questions in general and give an overview about how to solve these technical questions. Most of them will be on data structure and algorithms.
How to Prepare
- Try to solve the problem on your own (before looking at the hint and solution).
- Write the code on paper.
- Test the code on paper.
- Type the code as-is into the computer and compile/run it.
Things to Know
- Core data structures: linked list, tree/trie, graph, stack/queue, heap, vector/array list, hash table.
- Core algorithms: breadth-first search (BFS), depth-first search (DFS), binary search, merge sort, quicksort.
- Important concepts: bit manipulation, memory management (stack v.s. heap), recursion. dynamic programming (DP), big O notation (in time & space).
- Powers of 2 table.
Steps to Take
Interview questions may be supposed to be difficult. You are suggested to follow these steps below.
- Listen carefully
- Every piece of information in the question is useful.
- Draw an example
- Make sure the example is specific & large enough and it is not a special case.
- State a brute force
- Always start with a brute force method.
- Optimize
- Look for any unused information;
- Use a fresh example for inspiration;
- Solve it “incorrectly” to see what goes wrong;
- Make time v.s. space trade-off (pre-compute some information), like hash table and DP;
- Think about the best conceivable runtime (BCR).
- Walk through
- Get a feel of the solution so that it would be easier to implement it.
- Implement
- Modularize code, i.e., extract methods or classes;
- Error checking, i.e., assert or simple if statement for input validation;
- Good naming convention.
- Test
- Start with a conceptual test;
- Spot some weird codes;
- Use small cases;
- Use corner cases.
Optimization techniques
- Look for BUD (bottlenecks, unnecessary work, duplicated work);
- DIY (do it yourself), see what’s different between human’s mind and the computer;
- Simplify and then generalize;
- Build from base cases;
- Data structure brainstorm;
- Consider the best conceivable runtime (BCR).
To learn more about these techniques, see more examples at here.
Miscellaneous
- To handle incorrect answers: calm down and do not panic.
- If you have seen the questions before: better to admit that.
- To choose the programming language: choose wisely (suggest to use Java).
- Does the interview know it?
- Will the language make the code verbose?
- In this case, Java may not be as a good choice as Python.
- Does the language have built-in support for some data structures you will use?
- To write beautiful code: correct, efficient, simple, readable, maintainable, flexible, robust.