TGViewer
Coding Interview Resources Coding Interview Resources @crackingthecodinginterview · 52.2K subscribers
Post #3237 991
Here’s a DSA problem-solving cheat sheet that will help you solve 90–95% of questions that come your way.

♦ If the input is an array or string:
• Is the array sorted?
– Yes: Use Binary Search or Two Pointers.
– No: Move to the next checks.
• What is the question asking?
– Number of ways to do something / Max-Min of something:
▪ If decisions are dependent on each other, use Dynamic Programming.
▪ If decisions are independent, use Greedy.
– Is something possible?
▪ Try Backtracking.
• Does it involve string manipulation?
– Prefix matching: Use Trie.
– Building strings or finding distances: Use Stack or Monotonic Stack.
• Is it about finding a specific element?
– Use a Hash Map or Set.
• Does it involve elements being added/removed in a sliding window fashion?
– Use a Sliding Window or Counting Hash Map.
• Is the problem about continuously finding the max/min element or removing them?
– Use a Heap or Monotonic Queue.

♦ If the input is a graph:
• Does the question involve finding the shortest path or the fewest steps?
– Yes: Use Breadth-First Search (BFS).
– No: Use Depth-First Search (DFS).

♦ If the input is a tree (probably binary):
• Does the question involve specific depths/levels?
– Yes: Use Breadth-First Search (BFS).
– No: Use Depth-First Search (DFS).

♦ If the input is a linked list:
• Does it involve detecting cycles?
– Use Fast and Slow Pointers.
• Does it involve reversing or modifications?
– Use a prev pointer for reversing.
– Use a dummy pointer for maintaining the original head.

This flow will help you quickly identify the optimal approach for most DSA problems.

React ❤️ for more
  • ❤ 5
More from @crackingthecodinginterview
  1. Sep 29, 2026✅ Daily Coding Habits That Make You a Better Developer 🧠💻✨ 1️⃣ Code Every Day (Even 30 M…
  2. Sep 29, 2026𝗙𝗥𝗘𝗘 𝗥𝗲𝘀𝗼𝘂𝗿𝗰𝗲𝘀 𝗧𝗼 𝗟𝗲𝗮𝗿𝗻 𝗔𝗜 𝗶𝗻 𝟮𝟬𝟮𝟲🚀 ​ Explore 6 free resource…
  3. Sep 28, 2026🎓 𝗛𝗔𝗥𝗩𝗔𝗥𝗗 𝗨𝗡𝗜𝗩𝗘𝗥𝗦𝗜𝗧𝗬 𝗙𝗥𝗘𝗘 𝗢𝗡𝗟𝗜𝗡𝗘 𝗖𝗢𝗨𝗥𝗦𝗘𝗦 😍 Dreaming of…
  4. Sep 27, 2026Top 21 skills to learn this year 👇 1. Artificial Intelligence and Machine Learning: Under…
  5. Sep 27, 2026𝗟𝗲𝘃𝗲𝗹 𝗨𝗽 𝗬𝗼𝘂𝗿 𝗦𝗸𝗶𝗹𝗹𝘀 𝘄𝗶𝘁𝗵 𝗧𝗵𝗲𝘀𝗲 𝗚𝗮𝗺𝗲-𝗖𝗵𝗮𝗻𝗴𝗶𝗻𝗴 𝗖𝗼𝘂…
  6. Sep 26, 2026Deployment and Real-World Practice 91. What is model deployment? 92. What is batch vs real…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →