Problem Solving #
If you are following up on my earlier breakdown of essential developer traits blog. You seem genuinely interested in self-improvement—probably a junior or mid-level developer looking to level up.
That’s good because problem-solving is muscle memory; you can’t learn it from diagrams alone. Looking back at my previous blog, I emphasized curiosity and resilience as pillars, so now I will drill into concrete methods without overwhelming. The challenge is balancing breadth (many techniques) with depth (usable advice).
Key angles to cover: #
- Foundation: You’ll need the basics—data structures, algorithms—but framed as tools, not academic exercises.
- Practice Formats: Competitive coding? Real-world projects? Debugging? Each has pros/cons.
- Mindset Shifts: How to reframe "I’m stuck" as part of the process.
Also, we might be struggling with: #
- Imposter syndrome when facing hard bugs.
- Not knowing where to start on large problems.
- Time pressure skipping deep thinking. I’ll avoid jargon-heavy terms ("dynamic programming") unless examples show why they matter.
Don't worry about understanding things earlier or not keeping consistency. struggle is normal for people, even senior devs hit walls. Better retry than sinking
You don't need know everything to start show-up in interviews, just express that you can go forward without pushback yourself.
In Short: #
- Core Principles
(why mindset > memorization) - Concrete Techniques
(decomposition, rubber ducking) - Practice Sources
(LeetCode vs. real work) - Meta-Skills
(documenting failures, collaboration).
problem-solving is learnable, not innate genius.
Oh, and be warn against tutorial hell where you may follow guides without struggling independently. That’s a common trap.
LeetCode is an online platform that offers a vast collection of coding problems aimed at improving programming and algorithmic skills. It's especially popular among software engineers who are preparing for technical interviews at companies like Google, Amazon, Meta, Microsoft, etc.
What LeetCode Offers: #
- Algorithm and Data Structure Problems: From easy to extremely hard, covering topics like arrays, trees, dynamic programming, graphs, heaps, etc.
- Company-Specific Problem Sets: Problems tagged by company (e.g., "Amazon 2024 interview questions").
- Contest Platform: Weekly contests that mimic real-time competitive programming.
- Discussion Boards: Community solutions, explanations, and interview experiences.
- Mock Interviews: Tools to simulate real interview settings.
- Premium Subscription (optional): Unlocks detailed company-specific question sets and advanced analytics.
Now, Let's solve one of famously easy problem : Two Sum in TypeScript, step-by-step, including explanation.
Problem Summary (again for clarity): #
Given an array nums and a target number, return the indices of the two numbers in the array that add up to the target.
Example:Input: nums = [2, 7, 11, 15], target = 9Output: [0, 1]// Because nums[0] + nums[1] = 2 + 7 = 9
Intuition: #
- We can loop through the array.
- For each number, calculate the difference needed to reach the target.
- Store the number’s index in a map, so we can check if the difference is already seen.
TypeScript Solution: #
function twoSum(nums: number[], target: number): number[] { const map = new Map<number, number>(); // value -> index for (let i = 0; i < nums.length; i++) { const current = nums[i]; const difference = target - current; if (map.has(difference)) { return [map.get(difference)!, i]; // "!" tells TypeScript we are sure it's not undefined } map.set(current, i); // store current number with its index } return []; // if no solution found (LeetCode assumes one exists)}
How It Works: #
mapstores each number and its index as we go.For each number:
- We check if the needed pair (i.e.,
target - current) already exists in the map. - If it does, we’ve found the two indices.
- We check if the needed pair (i.e.,
We return those indices.
Example Run: #
nums = [2, 7, 11, 15], target = 9 i = 0 → current = 2, diff = 7 → map = {2: 0}i = 1 → current = 7, diff = 2 → 2 is in map → return [0, 1]
Notes: #
- Time Complexity: O(n) — only one pass through the array.
- Space Complexity: O(n) — for the hash map.
Here's a step-by-step visual breakdown of how the twoSum function works for this input:
Input: #
nums = [2, 7, 11, 15]target = 9
We’ll walk through each step of the loop and show:
- Current number
- Needed difference (
target - current) - What's in the map
- Whether we found a match
Iteration Steps: #
➤ Step 1: #
i = 0current = nums[0] = 2difference = target - current = 9 - 2 = 7map = {}→ 7 not in map → store 2 with index 0 in map
- Map becomes:
{ 2 => 0 }
➤ Step 2: #
i = 1current = nums[1] = 7difference = 9 - 7 = 2map = { 2 => 0 }→ 2 **is** in map!→ return [map.get(2), 1] → return [0, 1]
- We’ve found the solution.
Final Output: #
[0, 1]
Because:
nums[0] + nums[1] = 2 + 7 = 9 (target)
Visualization Table: #
| i | current | needed (target - current) | map before | map after | action |
|---|---|---|---|---|---|
| 0 | 2 | 7 | {} | {2 → 0} | Store 2 |
| 1 | 7 | 2 | {2 → 0} | {2 → 0} | Found! return [0, 1] |
Does LeetCode Help with Algorithm Practice? #
Yes — if used properly.
Benefits: #
- Structured Practice: Problems are well-categorized and curated.
- Depth and Variety: Covers nearly every algorithmic topic.
- Real Interview Alignment: Many questions are similar or identical to actual interview problems.
- Improves Problem-Solving Skills: Helps build a strong foundation in algorithms, data structures, and coding efficiency.
Caveats: #
- Can Become Addictive Without Direction: Solving problems randomly might feel productive but lack focus.
- May Neglect System Design or Soft Skills: It's great for coding interviews but not a full picture of what tech interviews involve.
- Some Problems Are "LeetCode Hard": Meaning they may not reflect practical or real-world interview expectations.
How to Get the Most Out of LeetCode: #
- Follow a progression path (e.g., Easy → Medium → Hard).
- Focus on patterns rather than memorizing specific problems.
- Review and revisit your incorrect or inefficient solutions.
- Pair with study plans like "NeetCode 150", "Blind 75", or LeetCode’s curated lists.
- Balance with other prep areas, like system design, behavioral questions, and mock interviews.
Summary: #
LeetCode is one of the best platforms for algorithm practice, especially for technical interview preparation. Just be sure to use it strategically and in combination with broader interview prep.


Loading discussion...