How to solve problems Flashcards
1st things 1st: your value to the company is your ability to solve problems
Understanding > memorizing
this is what the technical interview attempts to answer
but.. the thing is, above all you need to be able to show your thought process and knowing the tradeoffs between data structures and algorithms.
To do this, you need to:
- have a consistent process
- understand the tradeoffs between data structures and algorithms
- communicate clearly
- understanding of Big O
- problem solving process
- understanding of data structures and algorithms
Section Overview:
Solve a coding problem just like we would in an interview and analyze the different solutions.
What companies are looking for:
At the beginning and end of the day, the company doesn’t expect you to know everything, just a few things well (coding, technical foundations, communication). And to know how to break down problems and find answers
- Analytical (thought/problem solving process)
- Coding (readable, clean, and organized)
- Technical skills
- Communication skills
technical skills: why use a certain data structure over another, why use a certain algorithm over another
Technical Foundation: Data Structures
Lists/Arrays Stacks Queues Linked Lists Trees Tries Graphs Hash Tables
Technical Foundation: Algorithms
Sorting Dynamic Programming BFS (searching) DFS (searching) Recursion
Step by step through a problem
- When the interviewer says the question, write down the key points at the top (sorted array, etc..) Make sure you have all the details. Show how you
- Double check: what are the inputs? what are the outputs?
- What is the most important value of the problem. Do you have time, space and memory, etc… what is the main goal?
- Don’t be annoying and ask too many questions.
- Start with the naive/brute force approach. First thing that comes into mind. It shows that you’re able to think well and critically.
- Tell them why this approach is not the best (i.e. O(n^2) or higher, not readable, etc…)
- Walk thru your approach, comment things and see where you may be able to break things. Any repetition, bottlenecks (like O(n^2), or unnecessary ..
- Before you start coding, walk thru your code and write down the steps you are going to do
- Modularize your code from the beginning. Break up your code into sensible small pieces and add just comments if you need to
- Start actually writing your code now. Keep in mind that the more you prepare and understand what you need to code, the better the whiteboard session will go
- Think about error checks and how you can break this code. Never make assumptions about the input. Assume users are trying to break your code
- Use descriptive and concise variable names that make your code readable
- Test your code: check for no params, 0, undefined, null, massive lists, async code, etc… Ask the interviewer if we can make assumptions about
- Finally talk to the interviewer where you would improve the code. Does it work? Are there different approaches? Is it readable? What would you
- If your interviewer is happy with the solution, the interview usually ends here. It is also common that the interviewer asks you extension questions