Read: Get Ready for 401
Solving Problems
How to Solve Programming Problems
Common mistakes
When most programmers are given a programming problem in an interview, they make several key mistakes. The most severe of those is the improper allocation of time.
If you have heard the saying “measure twice and cut once,” then you are probably familiar with the idea of spending upfront time to make sure something is done right, rather than diving right in.
The most common mistake I see when conducting interviews or watching someone try to solve a programming problem is they try to start writing code as soon as possible.
A simple set of steps
-
Read the problem completely twice. : This is the single most important step. You may even want to read the problem 3 or 4 times.
- Solve the problem manually with 3 sets of sample data. : It is very important to solve the problem manually first, so that you know what you are going to automate, otherwise you are just slinging code around
- Optimize the manual steps. : People often don’t realize how valuable this step is. It is much easier to rearrange and reconstruct and idea or algorithm in your head than it is in code
- Write the manual steps as comments or pseudo-code. : By doing this, we can know exactly what the structure of the code we are going to write is going to look like which makes the job of filling in the actual code later trivial.
- Replace the comments or pseudo-code with real code. : This step should be extremely easy at this point. If you have done all the other steps, this step involves no problem solving at all.
- Optimize the real code.
———————————————————————————————————————–
Act like you make $1000/hr
-
“Living in frenzy is a sign we’ve squandered too much.” -Niklas Goke In reality, a lot of people are living a frenzied, busy life. They wear their business as a badge of honor, and brag about their full schedules.
- Frankly, most people prefer the little dopamine boost of checking boxes on a to-do list than actually getting important work done.
- How do you value your time? Take stock of the things you did this week. How many of them were worthy of $1,000/hour?
- How many activities were a true waste of time? Value your time at what it deserves to be. The higher the value, the more important and productive work you’ll do — and the less trivial and mindless tasks you’ll get caught in. What you think is what you become.
- “Pretend your time is worth $1,000/hr. Would you spend five of them doing extra work for free? Would you waste one on being angry?” - Niklas Göke
- If you think your time is worth a few bucks an hour, that you’ll begin to act like it. You’ll find yourself saying “yes” to meaningless, pointless obligations.
But if, in your heart, you know your time is valuable…
People will recognize that.
People will respect that.
People will treat you differently.
How to think like a programmer
- “Everyone in this country should learn to program a computer, because it teaches you to think.” — Steve Jobs
- Why is this important?
The best way involves
a) having a framework and b) practicing it.
- “Almost all employers prioritize problem-solving skills first. Problem-solving skills are almost unanimously the most important qualification that employers look for….more than programming languages proficiency, debugging, and system design.
- Demonstrating computational thinking or the ability to break down large, complex problems is just as valuable (if not more so) than the baseline technical skills required for a job.” — Hacker Rank (2018 Developer Skills Report)
what should you do when you encounter a new problem?
- Understand : Know exactly what is being asked. Most hard problems are hard because you don’t understand them (hence why this is the first step).
- Plan : Don’t dive right into solving without a plan (and somehow hope you can muddle your way through). Plan your solution!
- Divide : Pay attention. This is the most important step of all.
- Stuck? : The difference is the best programmers/problem-solvers are more curious about bugs/errors than irritated. ———————————————————————
- “Just when you think you’ve successfully navigated one obstacle, another emerges. But that’s what keeps life interesting.[…]
- Life is a process of breaking through these impediments — a series of fortified lines that we must break through.
- Each time, you’ll learn something.
- Each time, you’ll develop strength, wisdom, and perspective.
-
Each time, a little more of the competition falls away. Until all that is left is you: the best version of you.” — Ryan Holiday (The Obstacle is the Way)
5 Whys
The 5 Whys technique is true to this tradition, and it is most effective when the answers come from people who have hands-on experience of the process or problem in question. The method is remarkably simple: when a problem occurs, you drill down to its root cause by asking “Why?” five times. Then, when a counter-measure becomes apparent, you follow it through to prevent the issue from recurring
- Assemble a Team
- Define the Problem
- Ask the First “Why?”
- Ask “Why?” Four More Times
- Know When to Stop
- Address the Root Cause(s)
- Monitor Your Measures
5 Whys Single_Lane

5 Whys multiple_lanes
