In this video, I worked on LeetCode 3740 (Minimum Distance Between Three Equal Elements I), an easy problem focused on finding patterns in arrays.
While solving this problem, I used a HashMap to store indices of each value and explored a new method: computeIfAbsent.
This helped simplify the process of grouping indices and made the implementation cleaner.
This was a good exercise in improving my understanding of HashMaps and writing cleaner Java code.
π Problem: Minimum Distance Between Three Equal Elements I
π‘ Focus: HashMap + grouping indices
Let me know if youβve used computeIfAbsent before or if this is new to you!
#leetcode #java #hashmap #coding #dsa #learning
Download
0 formats
No download links available.
DAY19 Leetcode | I Learned a New HashMap Trick Solving This π (LeetCode 3740) | NatokHD