AI Hints
Home›DSA in Python Tutorial›Interview Method
DSA in Python · Lesson 103 of 132

How to Solve Any Problem

A step by step method.

⏱ 2 min read▶ Video at 2:03:15🎓 Free
Watch this lesson in the DSA in Python courseWatch on YouTube ↗Full DSA in Python course

In a coding interview, the interviewer cares as much about how you think as whether you finish. A calm, repeatable method makes a huge difference. Here's one that works.

How to Solve Any Problem
From the video: How to Solve Any Problem
  • How you think matters
  • A calm method
  • One that works

Five steps

First, understand the problem. Repeat it back, and ask about edge cases, like empty input or duplicates. Second, work through a small example by hand. Third, describe a brute force solution, and its Big O. Fourth, improve it, using the clues and tools you know. Fifth, write the code, then test it out loud with your example and the edge cases.

  1. Understandask questions
  2. Examplesolve one by hand
  3. Brute forcesay its Big O
  4. Improveuse the right tool
  5. Code and testedge cases too
Five steps
From the video: Five steps

Habits that impress

Think out loud, so the interviewer can follow you, and help you. Name your variables clearly. Mention the time and space complexity without being asked. And if you're stuck, say what you're trying. Silence is the one thing that really hurts.

keyvalue
Think aloudshow your reasoning
Clear namesleft, right, seen
State Big Otime and space
Never go silentsay what you're trying

Summary

Understand, try an example, brute force, improve, then code and test. Next, we'll use that method on real interview problems, starting with water containers.

Key takeaways
  • Understand and ask
  • Brute force first
  • Test out loud
Next up: Practice: Most Water — two pointers again