Sitemap

Decoding the Problem: Choosing the Right Algorithmic Approach

10 min readJan 19, 2025

Give me six hours to chop down a tree and I will spend the first four sharpening the axe.
— Abraham Lincoln

Choosing the right approach to solve a coding problem is arguably as important as writing the code itself. While preparing for data structures and algorithms (DSA) for coding interviews or competitive programming, I often found myself stuck, not because I didn’t know the algorithms, but because I struggled to identify which algorithm or strategy to apply. Different problems inherently demand different solutions, and mastering the art of selecting the right approach can dramatically reduce problem-solving time and lead to more elegant and efficient code. Through my own learning process, I’ve compiled some key insights that I believe will be helpful to others facing the same challenge. This post explores various problem-solving strategies and offers guidance on choosing the most effective approach for different types of coding problems.

Press enter or click to view image in full size
Reference from google

Dynamic Programming (DP)

When to use:

  • Overlapping subproblems.
  • Optimal substructure (the solution to a problem depends on the solution to its subproblems).

Examples:

  • Fibonacci Sequence: Calculate the nth Fibonacci number.

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web
Already have an account? Sign in
Swatiomar

Written by Swatiomar

As a programmer, to keep learning and help ones who needs the skills to be a master, I am available to be a part of an adventurous journey….

No responses yet

To respond to this story,
get the free Medium app.

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store