What Debugging My DSA Mistakes Taught Me Recently, I realized something: The real learning didn’t happen when I got the solution right. It happened when I got it wrong. - Popped from a stack twice in one line. - Confused floor division with truncation in Python. - Stored values instead of indices and broke duplicate cases. - Used Kadane where prefix sum was required. Each mistake exposed a hidden assumption. I stopped memorizing patterns and started understanding invariants. The biggest shift wasn’t solving harder problems, it was asking better “why” questions. #DSA #Algorithms #Python
Debugging DSA Mistakes: Learning from Errors
More Relevant Posts
-
Day 69 Some problems look hard… until they teach you something valuable. #Day69 🧩 295. Find Median from Data Stream A challenging problem, but a great one for learning. What it teaches: • Using two heaps (min heap + max heap) together • Keeping the data stream balanced • Understanding how median changes with every insertion This problem really makes you think about the structure of data, not just the code. The more I analyze it from different angles, the clearer it becomes. Definitely one of those questions that deserves revision. Hard problems often become the best teachers. #LeetCode #DSA #Python #Heap #PriorityQueue #LearningInPublic #Consistency
To view or add a comment, sign in
-
-
🚀 Solved today’s GeeksforGeeks Problem of the Day: Course Schedule using Python 🐍 Problem: Given a number of courses and their prerequisites, determine whether it is possible to complete all courses. Approach: Implemented Topological Sorting using BFS (Kahn’s Algorithm) to detect cycles in the graph. ✔ Built adjacency list from prerequisites ✔ Calculated indegree of each course ✔ Started with courses having 0 indegree ✔ Processed nodes using BFS and reduced dependencies ✔ If all courses are completed → return True 💡 Key Insight: This problem is essentially about cycle detection in a directed graph. If a cycle exists, completing all courses is impossible. 💡 Concepts Used: Graph Traversal | Topological Sort | BFS | Cycle Detection This problem helped me strengthen my understanding of dependency resolution and graph-based problem solving 📚 #geekstreak60 #npci #geeksforgeeks #dsa #python #graphs #topologicalsort #codingpractice #problemSolving
To view or add a comment, sign in
-
-
Day x of building in public 🔨(I don't remember tbh) Today felt like two different worlds colliding — 📚 College: Selection Sort, Bubble Sort, Insertion Sort ⚡ Home: CRUD operations on FastAPI One is about understanding HOW computers think. The other is about building things people can actually use. Both matter. Most people learn sorting algorithms and forget them. I'm learning them AND shipping code the same day. That gap — between knowing and doing — is where most people stay stuck. Not me. Not anymore. #100DaysOfCode #FastAPI #Python #DSA #BuildingInPublic #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Solved Today’s POTD: Longest Subarray with At Most Two Distinct Integers on GeeksforGeeks using Python 🐍 Problem: Given an array of positive integers, find the length of the longest subarray that contains at most two distinct integers. Approach: Used the Sliding Window Technique + HashMap: • Maintained two pointers (left & right) • Used a frequency dictionary to track elements in the window • Shrunk the window whenever distinct elements became more than 2 • Continuously updated the maximum length This problem strengthened my understanding of: ✔️ Sliding window pattern ✔️ Handling “at most K distinct elements” problems ✔️ Efficient window expansion and shrinking 💡 Time Complexity: O(n) 💡 Space Complexity: O(1) Recognizing patterns makes medium problems manageable 💪 Consistency continues! #geekstreak60 #npci #geeksforgeeks #dsa #python #slidingwindow #arrays #problemsolving #learning
To view or add a comment, sign in
-
-
📅 Day 12 of My DSA Journey 🚀 Today I solved a problem on finding the length of the longest subarray with a given sum using the Prefix Sum + HashMap technique. 🔢 Problem: Given an array arr = [1,2,3,1,1,1,1] and target = 3, find the length of the longest subarray whose sum equals the target. 💡 Approach: • Maintain a running sum (prefix sum) • Use a hashmap to store first occurrence of each sum • Check if (current_sum - target) exists • Calculate subarray length and track maximum 🧠 Key Learning: Storing the first occurrence of prefix sum helps in getting the longest subarray efficiently in O(n) time. ✅ Output: 3 📌 This problem improved my understanding of optimizing subarray problems using prefix sums. #DSA #Python #CodingJourney #100DaysOfCode #Learning #ProblemSolving
To view or add a comment, sign in
-
-
Day 88 Back to tree basics again. #Day88 🧩 102. Binary Tree Level Order Traversal Simple but powerful pattern: • Use BFS with a queue • Process nodes level by level • For each level, collect values and push children into the queue What I realized: It’s not about differences or totals — it’s about processing nodes in layers. Tree problems become easy when you: → Choose the right traversal → Stick to the pattern Revision keeps these basics sharp. #LeetCode #DSA #Python #BinaryTree #BFS #LearningInPublic #Consistency
To view or add a comment, sign in
-
-
Most beginners think a variable is a complicated concept. It is not. A variable is just a labelled box. 📦 name = 'Haris' This means: → Create a box → Put a label on it that says 'name' → Put 'Haris' inside the box That is it. age = 20 → a box labelled age holding 20 score = 98.5 → a box labelled score holding 98.5 Python is just organizing boxes. Once I understood this, everything else made sense. I am currently on Week 1 of documenting my Python journey publicly. If you are learning too — follow along. 🧵 What concept confused you most when you started programming? 👇 #Python #Programming #LearnPython #BuildingInPublic #AI #MachineLearning #100DaysOfCode #TechPakistan
To view or add a comment, sign in
-
🚀 Solved Today’s POTD: Longest Substring with K Unique Characters on GeeksforGeeks using Python 🐍 Problem: Given a string and an integer k, find the length of the longest substring that contains exactly k distinct characters. If no such substring exists, return -1. Approach: Used the Sliding Window Technique with a HashMap: • Maintained two pointers to represent the window • Tracked character frequencies inside the window • Expanded the window while keeping at most k distinct characters • Shrunk the window whenever distinct characters exceeded k • Updated the maximum length when exactly k distinct characters were present This problem strengthened my understanding of: ✔️ Sliding window patterns ✔️ Efficient substring processing ✔️ Managing distinct elements using hash maps 💡 Time Complexity: O(n) 💡 Space Complexity: O(k) Consistency in solving DSA problems improves pattern recognition and problem-solving skills 💪 #geekstreak60 #npci #geeksforgeeks #dsa #python #strings #slidingwindow #problemsolving #codingjourney #learning
To view or add a comment, sign in
-
-
🚀 Day 9 of #100DaysOfCode Today’s problem: Valid Anagram ✅ 🔍 What I learned: How to check if two strings are anagrams Importance of sorting vs frequency counting Strengthened my understanding of strings & hashing concepts 💡 Approach: I used a simple and clean method: Sort both strings Compare them If equal → Anagram ✔️ 📊 Result: ✅ All test cases passed (54/54) ⏱️ Runtime: 19 ms 🔥 Key takeaway: Sometimes a simple solution is enough, but there’s always room to optimize using hash maps for better performance. Consistency > Perfection 💯 Let’s keep going! #LeetCode #DSA #CodingJourney #Day9 #Python #ProblemSolving
To view or add a comment, sign in
-
-
Python Clarity Series – Episode 13 Topic: *args and **kwargs Simplified 🤯 What are *args and **kwargs? Students fear this syntax. Let’s simplify. def total(*numbers): return sum(numbers) print(total(1, 2, 3)) 👉 *args collects multiple positional arguments into a tuple. Now: def student(**details): print(details) student(name="Ravi", marks=90) 👉 **kwargs collects named arguments into dictionary. 💡 Memory Trick: → Tuple ** → Dictionary This is heavily used in frameworks and advanced coding. Not hard. Just unfamiliar. #PythonConcepts #FutureDevelopers #LearnPython
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development