Day 22 of DSA Journey: Strings, HashMap, and Frequency Problems

🚀 Day 22 of my DSA Journey (LeetCode + Java) Today’s practice focused on Strings + HashMap + Character Frequency problems. All three questions required pattern-thinking and careful dry runs to avoid mistakes. ✅ Problems Solved Today: LC 205 – Isomorphic Strings LC 2194 – Cells in a Range on an Excel Sheet LC 383 – Ransom Note 🧠 My Experience Solving These: 🔸 205. Isomorphic Strings This problem looked easy at first, but it got complicated quickly. I first tried using one HashMap, but it failed because: One direction mapping is not enough Characters need to map both ways Then I created two HashMaps: map1 → s → t map2 → t → s With this, all cases passed and the solution became fully optimized. A great learning about bidirectional mapping. 🔸 2194. Cells in a Range on an Excel Sheet Initially, I didn’t understand what the problem was asking. Then I realized: Range is like "K1:L2" Columns vary (letters) Rows vary (numbers) Used a simple nested loop: Outer loop: columns Inner loop: rows Once understood, it became an easy and clean solution. 🔸 383. Ransom Note This problem was tricky because of frequency handling. I used an int[26] array to count characters of the magazine. Count frequency Reduce frequency while checking ransom note If any count < 0 → not possible Dry runs helped me catch mistakes and finalize an O(M + N) optimized solution. 📌 Key Takeaway Today: String problems are all about patterns and frequency logic. ✔ Some problems need two-way mapping ✔ Some require simple range expansion ✔ Many become easy if you use frequency arrays / HashMap ✔ Dry runs remove 90% of mistakes Every day my problem-solving mindset is improving. Consistency is building confidence! 💪 On to Day 23! 🚀 #DSA #LeetCode #Java #HashMap #Strings #CodingJourney #ProblemSolving #Consistency #LearningDaily

To view or add a comment, sign in

Explore content categories