Day 4: From Brute Force to Optimization - My Data Structures & Algorithms Learning Journey ๐

TL;DR: Today I tackled Container With Most Water and Roman to Integer problems, focusing on building solid foundations before optimization. Here's what I learned and how you can apply these concepts in technical interviews.
๐ฏ What HR Recruiters Need to Know About This Post
For Hiring Managers & Technical Recruiters: This post demonstrates:
โ Problem-solving methodology - I build brute force solutions first, then optimize
โ Learning agility - Actively researching advanced techniques (Two Pointer method)
โ Code documentation - All solutions available on GitHub with clear explanations
โ Consistency - Day 4 of a committed 90-day learning journey
โ Growth mindset - Acknowledging inefficiencies while planning improvements
๐ Today's Technical Deep Dive
Problem 1: Container With Most Water - The Foundation-First Approach
The Challenge: Find two lines that form a container holding the maximum amount of water.
My Strategy:
Start with Brute Force (O(nยฒ) time complexity)
Check every possible pair of lines
Calculate area for each pair
Track maximum area found
Why Brute Force First?
๐ง Builds logical thinking - Essential for technical interviews
๐ Reveals edge cases - Helps understand the problem deeply
๐ก Interview strategy - Many companies appreciate seeing your thought process
from typing import List
class Solution:
def maxArea(self, height: List[int]) -> int:
maxvol = 0 # Stores the maximum area found
# Try all possible pairs of lines (brute-force approach)
for i in range(len(height) - 1):
for j in range(i + 1, len(height)):
# Water is limited by the shorter line
minheight = min(height[i], height[j])
# Width is the horizontal distance between lines
width = j - i
# Area = minheight * width
temp = minheight * width
# Update max area if current is greater
maxvol = max(maxvol, temp)
return maxvol
Next Step: Two Pointer Optimization (O(n) solution)
I'm studying this technique for tomorrow's implementation
This shows progression from basic to advanced solutions
Problem 2: Roman to Integer - Clean String Processing
Key Learning: Dictionary mapping + reverse traversal for handling subtraction cases.
class Solution:
def romanToInt(self, s: str) -> int:
# Dictionary to map Roman numerals to their integer values
roman = {
'I': 1,
'V': 5,
'X': 10,
'L': 50,
'C': 100,
'D': 500,
'M': 1000
}
total = 0 # This will store the final integer result
prev_value = 0 # Tracks the value of the previous Roman numeral
# Iterate over the string in reverse (right to left)
for char in reversed(s):
value = roman[char] # Get the integer value of the current Roman numeral
# If the current value is less than the previous one, we subtract it
# Example: IV -> 5 (V) comes before 1 (I), so we subtract 1 -> total = 4
if value < prev_value:
total -= value
else:
# Otherwise, we add it to the total
total += value
# Update prev_value to the current one for the next iteration
prev_value = value
return total # Return the final converted integer
๐ฏ Key Takeaways for Beginners Following This Journey
1. Master the Basics Before Optimization
Brute force solutions show you understand the problem
Optimization comes naturally once logic is solid
Interview tip: Always explain your brute force approach first
2. Time Complexity Matters (But Understanding Matters More)
O(nยฒ) vs O(n) - know the difference
Be ready to discuss trade-offs in interviews
Practice explaining complexity in simple terms
3. Document Your Learning Process
GitHub repository with clean, commented code
Shows continuous learning to potential employers
Helps other developers learn from your journey
๐ Progress Tracking & Metrics
Day 4 Stats:
โ 2 Problems solved
โ 1 New technique researched (Two Pointer)
โ Code documented and pushed to GitHub
โ Learning methodology refined
Consistency Score: 4/90 days completed (4.4% progress) ๐ฅ
๐ Resources & Links
GitHub Repository: Day 4 Solutions
Problem Sources: LeetCode, HackerRank
Next Study Topic: Two Pointer Technique Implementation
๐ผ Why This Matters for Your Career
For Job Seekers:
Demonstrates consistent learning habits
Shows ability to break down complex problems
Proves commitment to technical growth
Documents problem-solving methodology
For Students:
Learn alongside my journey
See real problem-solving in action
Understand interview preparation strategies
Build your own coding discipline
๐ข Join My Learning Journey!
Following my #90DaysOfDSA challenge?
โญ Star my GitHub repository
๐ฌ Share your own solutions in the comments
๐ Follow for daily updates and insights
๐ง Connect with me for collaboration opportunities
For Recruiters: Feel free to reach out - I'm actively seeking ai development opportunities and would love to discuss how my problem-solving approach can benefit your team.
Day 4 complete! Tomorrow we optimize. The journey continues... ๐ช
Tags: #DSA #DataStructures #Algorithms #TechnicalInterview #SoftwareDeveloper #ProblemSolving #CodingChallenge #JobSearch #Programming #LeetCode #GitHub #CareerGrowth #TechSkills
Subscribe to my newsletter
Read articles from Piyush Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Piyush Kumar
Piyush Kumar
Hey there! Iโm Piyush Kumar, a curious mind on a mission to master Data Structures & Algorithms โ one problem at a time. Iโm not just solving questions; Iโm building habits, debugging my thinking, and documenting the highs and lows of my coding grind. Whether itโs arrays at midnight, graph theory before coffee, or that satisfying โACโ moment after 17 failed attempts โ Iโm sharing it all openly. ๐ Currently on a 90-day DSA challenge, I post daily blogs and code logs that unpack: Real-world problem-solving strategies Patterns and techniques I learn (and unlearn) Honest reflections on growth, failure, and consistency Along the way, Iโm also exploring how to apply AI to meaningful problems โ because I believe in learning out loud and building in public. Letโs connect if youโre into: Open learning journeys ๐ Problem-solving and pattern recognition ๐ง Building cool things with code โ๏ธ โก Follow along and letโs decode DSA โ together!