Day 2 DSA LeetCode Practice Fundamentals

Day 2 | DSA + LeetCode Practice 🚀 Continuing my #100DaysOfCode journey by focusing on problem-solving and strengthening fundamentals. ✅ Problems Solved Today: Leetcode #3 Longest Substring Without Repeating Characters 🔹 Approach: Sliding Window + Hash Set 🔹 Logic: • Used two pointers to maintain a dynamic window • Stored characters in a set to track duplicates • When a duplicate appeared, moved the left pointer and adjusted the window • Tracked the maximum window length at each step 📌 Key Learning: The sliding window technique helps optimize brute-force solutions to O(n) time complexity. Leetcode #4 Median of Two Sorted Arrays 🔹 Approach: Binary Search on the smaller array 🔹 Logic: • Applied the idea of partitioning two sorted arrays • Used binary search to find the correct partition where left-side elements are less than or equal to right-side elements • Calculated the median based on whether the combined length was even or odd 📌 Key Learning: Binary search is not just for searching—it is a powerful tool for solving optimization problems efficiently. 📌 Day 2 Takeaway: Hard problems may feel overwhelming at first, but once the core idea is clear, the solution becomes much more intuitive. Moving on to Day 3 🔁 #Day2 #100DaysOfCode #LeetCode #DSA #ProblemSolving #CPP #LearningInPublic #SoftwareEngineering 🚀

To view or add a comment, sign in

Explore content categories