Solved LeetCode problem 2006 with hash map and frequency counting

🗓 Day 5 / 100 – #100DaysOfLeetCode 📌 Problem 2006: Count Number of Pairs With Absolute Difference K The task was to count the number of pairs (i, j) in an array such that the absolute difference between the two elements equals k. 🧠 My Approach: Used a hash map (Counter) to store the frequency of each element. For every number, checked how many times num + k (or equivalently num - k) appears. Accumulated the count efficiently without double-counting pairs. ⏱ Time Complexity: O(n) 💾 Space Complexity: O(n) 💡 Key Learning: This problem helped strengthen my grasp of hash maps and frequency-based counting — a powerful pattern that simplifies many pair-count and difference problems. Every problem adds clarity and confidence — one step closer to mastery 🚀 #100DaysOfLeetCode #LeetCodeChallenge #Python #ProblemSolving #HashMap #DataStructures #Algorithms #DSA #CodingJourney #CodingChallenge #CodeEveryday #CompetitiveProgramming #SoftwareEngineering #LearningInPublic #DeveloperJourney #TechStudent #CodingCommunity #CareerGrowth #KeepLearning #Programmer #LogicBuilding #TechCareer

  • graphical user interface, application

To view or add a comment, sign in

Explore content categories