Minimum Absolute Distance Between Mirror Pairs in Array

🚀 Day 216 of #300DaysOfCoding 💡 Solved: Minimum Absolute Distance Between Mirror Pairs (LeetCode 3761) Today’s problem was a great mix of hashing + number manipulation that tested both logic and attention to detail. 🔍 Problem Summary: Given an array, find the minimum distance between indices (i, j) such that: 👉 reverse(nums[i]) == nums[j] and i < j ⚡ Key Insight: Instead of checking all pairs (which would be O(n²)), we optimize using a HashMap. Store reversed values while iterating Check if the current number already exists in the map Update the minimum distance 🧠 What I Learned: Direction of logic matters a lot in hashing problems Small mistakes in mapping can lead to wrong answers Always dry run edge cases like [120, 21] ⏱️ Complexity: Time: O(n) Space: O(n) 🔥 Takeaway: Efficient problem solving is not just about knowing concepts, but applying them in the right direction. Consistency is the real game changer — showing up every single day 💯 #LeetCode #DSA #CodingJourney #PlacementPreparation #SoftwareEngineering #HashMap #ProblemSolving #Consistency #LearningEveryday

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories