Solved Minimum Absolute Distance Between Mirror Pairs on LeetCode with HashMap

🎉 Day 13 of My 100-Day Programming Challenge! 🚀 Today, I solved the “Minimum Absolute Distance Between Mirror Pairs” problem on LeetCode. The goal is to find the minimum index distance between pairs where one number is the reverse of the other. 🧩 🔍 Approach: I used a HashMap + number reversal technique to efficiently track and compare mirror pairs. ⚙️ Steps: • Traverse the array from left to right • Reverse the current number • Check if the current number already exists in the map • If yes → calculate distance using i - previousIndex • Store the reversed number in the map for future matches 💡 Key Insights: ✔ Reversing numbers helps identify mirror pairs quickly ✔ HashMap enables O(1) lookup for efficient comparison ✔ Single pass solution makes it optimal 🧠 Complexity: • Time Complexity: O(n × d) (d = number of digits) • Space Complexity: O(n) A great problem to strengthen concepts in Hashing, Number Manipulation, and Optimization. Consistency continues — let’s keep building! 💻🔥 #100DaysOfCode #Java #LeetCode #DSA #HashMap #Programming #CodingChallenge

  • text

To view or add a comment, sign in

Explore content categories